The PlayerState is null (I currently have this code under BeginPlay), but where would I add it? Currently lost on when exactly player state is not null and read that sometimes it becomes null.
Iâm pretty sure CurrentPlayerState is a custom variable youâve made.
If youâre trying to get a playerâs state, you can use the GetPlayerState() function on any pawn.
Though, the player state wonât be of much use to you in this situation since as long as the player itself isnât null, itâs state wonât be null.
Try adding a delay of a couple of seconds before you try to access the Player State. Iâve found that things sometimes need some time to be created/synchronized (if youâre making a multiplayer game).
I fixed with setting the default player state to the custom one I made then setting CurrentPlayerState then casting my custom class to GetPlayerState()
In multiplayer PlayerState might not be initialized in begin play, so PlayerController has âBeginPlayingStateâ: âPawn has been possessed, so changing state to NAME_Playing. Start it walking and begin playing with it.â
If you access those params in BeginPlayingState instead of BeginPlay, it wonât be null.