[Multiplayer] Problem about architeture and best way to spawn network objects inside prefab

Hey guys, how you doing? (Im new at the discussions, i dont know if the post is in the right place)

I’ve been trying to create a game with netcode for gameobjects and im doing pretty good, But im stuck in something that i dont know how to solve, here is the problem:

My game is basically something like a multiplayer online the sims, the player after create the character he can choose a room to start with, he can choose between 3 ones that are enable/disabled objects already on the scene.

In the scene i have a couch that has inside 3 child objects with network object inside it, with this i can use network variables and sync between the players that join the room if the sit is taken and who is sitting in that place, etc. something like this:

the GameObject couch is the mesh of a sofa and SitAction’s are colliders inside the couch to define the place the player is gonna sit. When the couch is already in the scene everything works fine, i make some ServerRPC calls to make the player sit/lift from the couch and everything works well.

The problem is, the host player (if he is a premium player) he can make upgrades to the room:

so after the player chooses the premium room he wants to add to the place i instantiate a new prefab room that contains the same feature that i already have in the scene (couch gameobject with sitaction children).

but now i got a problem, the network objects inside the couch from the recently room instantiated room are not spawned (GetComponent().Spawn()). Therefore, if the networObject is not spawned i cant call RPC methods.

I tried to spawn myself by code but i got a lot of exceptions like

And other problem is that when i spawn by code they move the sitActions(gameobject that has networkobject) all them to root scene and lose the parents objects (Couch) that it extremely necessary to be child from couch.

I tried to reparenting as well but this is take too much specific code to do it.

Anyway,

There is a better approach to this?

Solved. I had the misconception that child objects with script that use network variables need to have their own network object. But actually it didn’t, if your prefab has a network object at the root, its child objects will be able to use all the functionality of network behaviors, this is quite strange, but it worked. Well :man_shrugging: