- Home /
How to spawn a player object with multiple subobjects using UNet?
Most of the documents and tutorials I found online are about how to use unet to spawn a player with a single prefab(and a single NetworkID). But what if the player have multiple components (subobjects) which need to be synced ? For example, how to create a player as a robot composed of head,torso, arms and legs, and each part has its own hitpoint, transform properties?
Answer by Legacy7005 · Sep 15, 2016 at 12:44 PM
Can't you just add all those multiple components inside an Empty Object so that it count as one prefab?
No it won't work. If all those components do not need to be synced seperately at run time, using one prefab to include them all would be O$$anonymous$$. But in the situation I mentioned above, each component belongs to the player logically, meanwhile each of them has its own hitpoints, transforms and other properties, that need to be synced during play-time.
One problem with UNet I encountered is, if I want to sync the player's child objects with codes such as [synvar], the object need to have a networkID. But the prefab of player can have only one networkID, and it must also be added to the root object of the prefab. So how can I handle those child objects? Or is there some kind of workaround?
Your answer
![](https://koobas.hobune.stream/wayback/20220612092830im_/https://answers.unity.com/themes/thub/images/avi.jpg)