Let's solve this once and for all... Pawn Possession in Multiplayer?

After hours of pouring over my code, I cannot for the life of me get my Pawn Possession to replicate over a network. The Pawn is not possessed on either the Server or the Client on begin play (and likely any other event, but I haven’t been able to try that yet), and my player-controller-based camera just sits at spawn looking aimlessly into the distance. I can SEE the Pawn’s on both Server and Client, but I can’t control them.

I’ve google’d it multiple times, and it seems that there are issues with possessing a pawn over a network. See , , and . There are quite literally tens if not hundreds of post on Answerhub about replicating possession of a different pawn through network, and there doesn’t seem to be a definitive answer.

So, ‘s my PlayerControllers’ overridden ‘Possess’ function, can anybody tell me why it just won’t work? It’s not doing anything special, and for the moment Super::Possess doesn’t work on either Listen Server or Dedicated Server.

void ABZGame_PlayerController::Possess(APawn* aPawn)


	UBZGame_GameObjectComponent* NewGameObj = GetGameObjectComponentFromPawn();

My Server handles Spawning the Pawns (At least, it should right?). It seems as though there’s a lot of extra functionality / steps one must take to allow successful pawn possession in Multiplayer. I’ve trawled through ShooterGame and nothing immediately jumps out at me. Could do with some Documentation on this stuff… but C++ doesn’t seem to get much documentation attention :frowning:

I prefer to just spawn the default pawn using game mode.
virtual APawn * SpawnDefaultPawnFor(AController * NewPlayer, class AActor * StartSpot)

Following 's code, the UWorld::SpawnActor has some interesting stuff in it:

Look at that AddNetworkActor and stuff like:

// Broadcast notification of spawn

Seems like you might want to check those out?

Do you actually override that function to do that? I just assumed this kind of thing would be handled auto-magically as ShooterGame doesn’t have that function overridden in it’s gamemode.

It’s just bizarre because ShooterGame doesn’t seem to do anything special or modify the Spawning for Default Pawn’s at all, I can’t see any point where the GameMode overrides any spawning function and tells a PlayerController which Pawn to possess. However, it does do some ‘stuff’ with UniquePlayerID() in Player Controllers… Could really do with some Developer feedback on this one, or comments on SG’s method. Thanks for the links either way!

No its not over-riden i just use a RPC call to get the server to spawn the Pawn.
And if i remember correctly it should have the controller posses the new Pawn automagicly.

I do how ever over-ride GetPlayerStart and so on so i can determin/ select the best spawn for the player.

Am at work (day job) atm but i will see if i can`t get some example code up for you.
In the mean while check out How to Possess Pawns in Blueprint

Thanks ,

I’ve since realised that this part seemed to be working okay, the problem I had was with the ‘Attachment’ of the SpringArm to the Pawn, the Clients can’t use the ‘GetPawn’ function, they just give me an access Violation. What I’d have to do instead is send the pawn reference to the player controller from the pawn, and call the functions based on that. Really awkward though.

This thread is where I got to with it, by all means have a look, it’s still not working 100% correctly

I used something similar to this one last night to get it working.