How to parent and network object a grandchildren that doesnt have network object

Lets say i have a network object player which has a child named,lets say, a laser gun(at this stage he doesnt have network object attached) and i want to connect to the gun a laser prefab(which has a network object attached) this laser prefab should be attached to this small hirrachy as in

player
laser gun
laser

ofcourse during game player can switch laser guns and lasers so should ne able to destroy them and build and reconnect them

what is the official or best way to do it?
thx!

Thx for the reply but The questions is about spawning in running time and in multyplayer netcode formation

The easiest way is to build an all-encompassing prefab that contains all switchable variations rather than dealing with the difficulties of network-parenting and its unnecessary overhead when there’s a simpler alternative.

For example:
Player

  • Weapons
    – RocketLauncher (inactive)
    – LaserGun (active)
    – PlasmaRifle (inactive)
    – ChickenTransmuter (inactive)
    – etc.

And then just enable/disable these game objects (or components) as the player switches weapons. You can do weapon upgrades in a similar fashion.

1 Like

thx allot!
i used some of this suggestions already and it helped

Its good cut around but srill i would like to see how the best way to deal with it if we are trying to parent and all this mess…

hope someone will know how can it be done easily

This resolved Github Issue walks a user through one way to attach an object picked up to an owner/client authoritative (NetworkTransform) player. CodeSmile’s approach is another recommended path to take.

1 Like