Destroying a child GameObject causes parent to be destroyed.

Assume I have a Soldier prefab with a child AK-47 GameObject both with a PhotonView. If I destroy the AK-47 in master client(via PhotonNetwork::Destroy() ) , the Soldier instance in the client destroyed instead of AK-47.

From what I gathered from the code the problem stems from both the Soldier and the AK-47 have the same InstantiationId but with different subId (hence different viewIDs) but since only the instantiationId is send over network the client destroys the Soldier GO which is definitely not what is expected.

So, Is there a way to destroy the AK-47 GO without touching Soldier in this case? I might instantiate AK-47 independently than add it to the Soldier but I don't think this will be mirrored in client unless I find a convoluted way to send this information to the client and replicate there.
Thanks in advance.


  • It's usually not good practice to have separate PhotonView on piece of equipment. You better treat weapon as player property and update it accordingly (e.g. attaching proper model to soldier) with 'Weapon' client custom property or by rpc calls changing weapons or even using OnPhotonSerializeView to send weapon type in each update.
    Destroying of subobjects looks like issue in Photon currently. I hope you can avoid using it.
Sign In or Register to comment.