cant read position of actor-reference in my character blueprint

Hi,

it should be a very simple task, but I am not able to :(((

Situation:
I made a Character Blueprint. I added a variable of type actor->reference and made it public via “editable”. I compiled and added a simple cube from the scene to it.

I made this character blueprint my standart pawn Class in the project settings.

Now I did it like in the picture:

So, when I play the level in “selected viewport” mode and press “P” I always got position 0,0,0 .

unreal4_reference_problem_04.PNG

When I stop playback I got an error message too, that means translated, “it cant read the reference”.

Thats why it is 0,0,0. When I then connect the “print string” with the “event tick”, it prints me out again the 0,0,0 position, but next it prints me the right value of the reference.

unreal4_reference_problem_02.PNG

Super interesting is, that when I now play the scene in “simulate” modus, it always prints me the right position of the reference, without toggling with 0,0,0 .

unreal4_reference_problem_03.PNG

What do I do wrong?

You’re probably not possessing the pawn when starting the game so another one is created. You should be able to see this in the world outlier. The one in the level works because it has the variable, the one that spawns doesn’t have the variable set to anything. You need to set the BP to auto possess for player 0 somewhere in the BP detail settings.

You made a variable called Player Start, but doesn’t have anything in it. You may need to either drop the actor that has that code in your level, then use the eye dropper tool to select the actor to follow, and it will work.

Or use a GetAllActorsOfClass node to get the actor you want to read from, and then asign the actor it returns to your variable on BeginPlay.