Take control of pawn - Multiplayer

Hello, I’m trying to figure out how to take control of a pawn in multiplayer.

  1. There’s a trigger box next to a pawn, and when you touch it, you’re supposed to take control of the pawn.

But instead, when a client hits the box, the server appears to take control.

where you call this function ? do server execute the posses function ? Btw all the possess or client-server request to possess you should put on the PlayerController Blueprint.

The player index you’re using to decide on which player controller is the target will only work in local multiplayer. In a client/server game everyone thinks they are player index 0. Instead, get GameState > Player Index, this will give you an array, get an index from that array > Get Owner > Cast to PlayerController.

Ok, this is what I have so far. It does the same: The client hits the trigger, but the server then takes control of the pawn when the client should:

Unless you are using a dedicated server, player 0 is the server.

Is there a quick way to get the client’s id #? Or do I need to make my own array of players and loop through that?

Oh, just realize simple way you can do, from the Other Actor, Cast it to Pawn, then GetController form that then just call Possess right away, you no need Client-Server for that, cause when you walk over something it happen on server side also, you can add a node HasAuthority to just make this one happen on server only.

I think you need to make your own array. However as Duncan suggests below, I’m not sure that you actually need to know who is who in this specific case.

That helped me too, thanks!