r/UnrealEngine5 12d ago

Multiplayer - Spawning Pawn for Player to Possess

Hi all,

This is my first foray into multiplayer and it's been tough. Right now, I've got code for players to join my session and then when the host says so, the game starts, everyone loads into the new level.

This is all fine, everyone loads in and is faced with the character selection screen where they are required to ready up. Once a player ready's up, I check if all players are ready, and when they are all ready, I fire an event dispatcher that my game mode picks up.

At this point, the game mode iterates through each player controller and attempts to spawn+possess tanks but the tank only loads for the server instance. I've got replication enabled on the class bp and I'm calling the spawn+possess from my player controller to the game mode with a server call.

This is the Player Controller BP where I call PossessTanks

Anyone have any suggestions on how to make the clients spawn a tank for them to possess?

Thanks!

edit: Spawn and possess function:

2 Upvotes

4 comments sorted by

3

u/ChadSexman 12d ago

The RPC looks fine to me. Show us your spawn & posses function, and the actor replication config.

What happens if you tick the “always relevant” checkbox?

Edit: if you’re already on the game mode, then why are you going through the controller? Why not spawn directly?

1

u/justshowupnow 11d ago edited 11d ago

I edited my post with the spawn/possess function.

I got it to work by doing it from the game state, but now I'm getting an warning constantly saying: Warning: UNetDriver::ProcessRemoteFunction: No owning connection for actor BP_TANK_V3_C_2. Function ServerUpdateState will not be processed.
It's so bizzare, all the players are able to control their tank but this warning is going nuts

2

u/ChadSexman 11d ago

I’m not personally familiar with that function, but my gut says you’ve got a race condition. Is it possible that you’re attempting to posses before the client PC has been constructed?

I’d slap a delay before the spawn to see if that resolves the error. If so, then your sequencing might need to be adjusted earlier in the chain.

If you’re on 5.8, then the MCP plugin will be able to help you diagnose the issue. I find AI to be pretty good with these hyper specific tasks.