ModelView + Controller pattern in multiplayer

Hi guys and gals!

I’m trying to set up a ModelView + Controller pattern in a multiplayer prototype, so my player prefab is a PlayerController, which is the players only entry point to the game, so it handles all input, etc.

So when the player chooses a unit to play as it spawns, and hooks itself into the PlayerController so the player can actually control it.

That’s the theory… In practice what I have is a case where I either the unit spawns on the current client and gets connected to the controller (but doesn’t show up on the server or other clients), or the unit gets spawned on the server and the clients, but doesn’t get connected to the local player. (I’d show code, but I’d rather not muddy the waters).

How can I initiate the spawning of an object on the local client and have it perpetuate to the server and other clients?

Ideally I want to have that connection between unit and controller established on server and all clients so that we can connect the unit back to their controller and do fancy things with that, and I learned that SyncVars are not the way to go.

I apologise if my question is a bit vague, any help would be great.

Thanks!

Why not let the local player decide who to spawn, send that to the server, let the server spawn the unit, and let the spawned unit register with the right player?

That’s the plan, didn’t know how.

I got it working now. I send the spawning of the unit to the server from the client via a Command, then send the connection request back to the client from the derver via a ClientRpc.

That seems to work for me, and should allow for the units to be swapped out (my next step).