Hey,
I’ve been playing with netcode for gameobjects the last weeks.
I was wondering how to synchronize differents places between player.
Taking Pokemon 1st Gen for exemple :
You have a top-down movement on a map divided in small places. On them you can go to another place, get targetted by rotating NPC or launch a battle.
How would you handle the updates of the game ?
First I tough of making a separate ‘map’, ‘battle’ and ‘npc’ Game Objects that olds everything
and let the client side to decide wich one to show depending on a “int currentMap” index.
(this would allows to hide other player GFX if they are not on the same map).
But, if the NPC is disabled on the Host, it won’t update on other clients (such as npc collisions and movements), right ?
One solution might be to remove any non-client logic from the Game Objects and run some logic on a list of ‘active map’.
I though of separating each places in a separate scene, but how to synchronize players on them ?
Would the Host be able to run server-side logic on each client loaded scenes ?
Plus, networkobjects aren’t initialize on default SceneLoad and Changing Host Scene would change all other players scenes.
What do you think of it ?
Thanks for reading, bye 
No. And generally all clients must have the same scenes loaded. You could implement custom scene management but there’s a LOT to consider and you’d throw out everything that already works about scene synchronization.
Assuming that going into battle removes the client from the world map, or only leaves a representative “marker” object that tells other players that the current player is in battle.
First, you’d teleport (I believe NetworkTransform has such a method) the player to some place below the current scene (but not too far eg stay within 5,000 units from origin due to well-known float accuracy limitations). Also spawn a marker object at the player’s previous position. You can use that also to record the player’s previous position as you teleport the player back and despawn the marker after the battle is over.
The battle arena you could load locally (additively) provided that you engineer the server-side logic so it does not rely on the arena itself. One way to implement that is to allow only movement on a plane in this mode and not allow participants to leave the arena / go outside the circular zone. On the client-side you can represent that visually with an additional “visuals only” additive scene while the server only keeps record of the battle origin point and the player/enemy locations and if necessary clamps them to remain within range.
It’ll be even easier if the battle is purely implemented as UI eg combatants do not move.
The main problem would be spacing out the battle arenas if there can be several battles happening close-by. You could assign each client a “depth” (negative Y coord) to battle on so that they won’t conflict with each other (if only visually).
Generally it will be easier to implement network players if the actual player prefab is an empty placeholder, a network player manager object so to speak. For all instances where a player may be in multiple places or may have multiple representations in the game, such as a corpse. You can spawn the actual player prefab with “spawn as player”.
1 Like
Thanks you for such a complete answer !
I couldn’t figure it out alone, but I now have a good practive session in sight
Hope you have a great day
Bye 