Possessing pawns on the server with an aicontroller replicates the pawns bReplicates is false

I’m not sure if this is intended behaviour or a bug but I recently came across this while trying to spawn some local only ai controlled characters.

I set my Character to not replciate (bReplicates = false). Then I was doing: Spawn Character, Spawn AIController, Posses the Character with the AIController. This works fine if I only do this on clients, ie each client gets a local ai controlled character. If you then do the same thing on the server however the server spawned characters will replicate to clients (even though thier bReplicates remains false on the server).

Stepping through OnPossess I can see the “offending” line is line 521 of Pawn.cpp, namely the call to


CopyRemoteRoleFrom(GetDefault<APawn>());

which then does a



GetWorld()->AddNetworkActor(this);

which looks to me to be what is causing the characters to be spawned on clients.

Does anyone know if this is intended or an actual bug?

I’ve just tested this in 4.25.4. Spawning a Pawn (with bReplicates disabled) on the server also spawned the pawn for clients. I’m pretty sure this is intended though, and that they have a good reason to why they do this, but yeah sometimes (for example lobby players?) I just want to spawn objects locally. I guess using dedicated servers would solve this issue?

Hey, thanks for checking!

Did you possess your pawn after spawning on server? (Or was it auto possesed based on the **AutoPossessAi **property of pawns). Because for me, things behaved as I would expect just spawning the pawn (ie only shows up on server) but the possession is the thing that makes things go weird.

It is such a core part of engine gameplay that I would also be very surprised if it isn’t intended. But equally it seems very strange to me the way it is. I ended up doing a questionable hack to get around the issue in the project where it came up. And yes, dedicated servers would “solve” the issue.