Possess on client not working properly

Say I have a “Human” blueprint that would start the infecting process when an event is triggered(This triggering process works well)

And I set a timer used for count down(This works well too)

When the time’s up, I want to make the current Human player turn in to a vampire (That is, unpossess from the human pawn, destroy it, and possess a newly spawned vampire pawn)

The problem I’m having here, is that it seems I can’t get the player controller for the client. If the human player is the listen server, everything is fine. But if the infected human player is a client, then the strange thing happens: The client will unpossess the pawn but it will NOT possess the newly spawned pawn, INSTEAD the server would come to possess it. Shouldn’t a call of Get Player Controller on a client return the local player controller so I can pass it thru RPC?

I know it’s a bad practice to do such stuff in the character blueprint…Just doing a test here

1 Like

I’m having a very similar issue, were you ever able to resolve things on your end?

Are you sure infected is only called on client? Maybe put a isLocallyControlled into a branch there to make sure only the owning client calls to the server.

Thanks for the reply even after I solved it 2 years ago ^_^, the problem was in fact that infected is first called on server so GetPlayerController with index 0 will return controller of the listen server player instead of the actual client player that is possessing the pawn, as mentioned above.

Hi, I actually solved it (2 years ago!). The problem was in fact that infected is first called on server so GetPlayerController with index 0 will return controller of the listen server player instead of the actual client player that is possessing the pawn. So INSTEAD OF GetPlayerController with index 0, I turned to use GetController which is a pawn function that returns the controller that is actually possessing the pawn(in this case, the client). In a word, replace that GetPlayerController with GetController.

1 Like

Lol, weird. This sorted as new in the list due to someone else commenting on it with no answer.

Ok in order to make this question not marked as new I’ll post my own answer to it.

GetPlayerController is called first on the server so with index 0 it will return controller of the listen server player instead of the actual client player that is possessing the pawn. So INSTEAD OF GetPlayerController with index 0, using GetController which is a pawn function that returns the controller that is actually possessing the pawn(in this case, the client) solved this.

1 Like