The Variable after set is NULL

I set a variable in begin play, but when I use it, it is NULL……
The type of this variable is a customized pawn. I store a ref of the pawn of the level in the game instance. In this actor, I want to use the pawn.
It’s OK If I use “Get Player Pawn” to set the Pawn variable.
I don’t know why :scream:


All I see here is you getting the value of PAWNMain from the game instance. Twice.

If you want to store the pawn ref in the game instance, you need to set it also :slight_smile:

I’ve set the PAWN_MAIN in the player controller.

Ok, but is that game instance reference valid?

It’s quite a convoluted way of doing things :thinking:

If you want a reference to the player in the GI, you can just set it on begin play in the GI

image

Except that doesn’t work - hold on :smiley: - ok it’s just not ready, this works

or

2 Likes

Thanks. Your code is working for game instance itself, but it doesn’t help to me.
I found a solution: using the ref of pawn in game instance directly but not by a local variable.

I really don’t know why it will not work if I use a local variable to ref the pawn!!! :scream:

1 Like