Accessing owner of PlayerState on multiplayer client
I have a custom property on a PlayerState, "craftColor", that determines the color of the possessed pawn's static mesh. I have this property set to replicate with a ReplicatedUsing callback.
The problem is that when I receive the replicated callback on a client, I don't have an obvious way to tie the current PlayerState to any specific pawn. GetOwner() returns null. I understand that PlayerControllers don't exist on all clients, but I was hoping there would still be a way to go from PlayerState -> Possessed Pawn.
I may be able to use PlayerState->PlayerId to find the pawn, but at that point it feels like I'm fighting the system.
Am I using PlayerState incorrectly? It really seems like the correct place to put something like a player selected color. Should I move the "craftColor" variable to the Pawn, or is there some access method I'm failing to see?
No, but what you could do is something like this, declared in your custom PlayerState header.
And then in your custom Pawn header.
answered Jan 28 '15 at 06:45 AM
Could you not also do this through the Pawn itself? The Pawn has a reference to the PlayerState so you could just watch for changes in the Pawn's tick.
If you wanted to do something Async you could setup a delegate that gets fired whenever you replicate the color variable.
answered Jan 27 '15 at 08:50 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here