0
\$\begingroup\$

I have a UI widget that will be tracking the in-game position of the sun (bottom left corner).

In-game screenshot featuring sun dial

When I try to get the sun's position, it can't find the sun actor even though (I think) I have a reference to it in the widget blueprint.

enter image description here

SunDial widget blueprint

All I get is a null reference error.

Null reference error for Sun actor screenshot

What am I doing wrong and how do I fix it?

\$\endgroup\$
4
  • \$\begingroup\$ How are you setting sun actor? I cannot see any event called that set the value of the actors. It seems that you didn't executed at begin play and as tick starts the value of SunActor is still null \$\endgroup\$ Jun 24 at 12:20
  • \$\begingroup\$ @SimoneLungarella, I'm using the Get All Actors with Tag and setting the tag to "Sun", then using a GET node to select the 0 index and using a Set node to set the actor variable. I currently only have one actor with that tag in my project, so the 0 index should get me the Sun...but it's not. \$\endgroup\$
    – bynary
    Jun 24 at 21:09
  • 1
    \$\begingroup\$ I see the code you are talking about but no one is calling it, you should link it to an event like BeginPlay to trigger it before the tick starts \$\endgroup\$ Jun 26 at 7:05
  • 1
    \$\begingroup\$ That was it, @SimoneLungarella. If you want to make that an official answer, I can upvote you. \$\endgroup\$
    – bynary
    Jun 27 at 14:46

1 Answer 1

1
\$\begingroup\$

An event that initialize your SunActor is required. The node GetAllActorsWithTag has an exec pin and it required to be linked to something. For example it can be linked to the begin play event that triggers before your tick event:

example

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .