So I’m just curious as to the ‘intended’ method of creating the pawns that players will be controlling in a networked game. Should they just be spawned via the default behaviour using player starts, or should they be specifically created on the server, and then given out to clients for possession somehow?
I ask because, with the default method, IsLocallyControlled() returns false on clients for the pawn they are controlling, as if the default way (tested in PIE) isn’t the way to go.
They way I do it is, I spawn them on the server and then tell the client to possess it. This works pretty nicely for me, except sometimes the client can’t possess it yet. I think this problem is due to me calling posses BEFORE it has spawned on the client. So what I do now is: Server spawns pawn–>tells client to posses–>clients wait 0.5 seconds---->tries to posses the newly spawned pawn.
I’m not sure what a CLEAN way is of doing that last part. Perhaps putting the pawn in a OnRep and when it’s fired possessing it? Epic surely knows a better way!
But yeah, I’m PRETTY sure, the server needs to do the spawning.
Do you mean to say that you explicitly spawn them on the server, and ignore the use of PlayerStart objects? And the ‘tells client to possess’ is an RPC you wrote, I presume, which gives the client the pawn to possess?
What i did is override the methods of SpawnDefaultPawnFor(…) in GameMode to suit my needs.
You stile need the RPC call to get the GameMode on the server but that handels a lot for you.
Also check out the PlayerStartsarray in the GameMode.