Phonton: Clients do not see child/parent relationships

Hello all,

The game:
I’m working on a 2D side-scrolling game that uses PUN (Photon Unity Network). When the game starts, the client that joins first creates the room for other clients to join.

The idea:
When instantiating a prefab, make it the child of another object; therefore the translation of the parent would also translate all children attached. In the game, the player and weapon get instantiated using:

GameObject myPlayer = PhotonNetwork.Instantiate("prefab", new Vector(x, y, z), Quaternion.Identity, 0);
GameObject weapon = PhotonNetwork.Instantiate("prefab", new Vector(x, y, z), Quaternion.Identity, 0);

note: prefab, x, y, and z have actual values. The prefab is located in the Resources folder. Each object has the “PhotonView” script attached as well.

Upon creation the instantiated (weapon) is made a child of the parent(player).

weapon.transform.parent = myPlayer.transform;

The idea works, and the weapon object(child) follows the player(parent) around with a separate movement script. The movement script is not part of the prefab, rather added upon creation.

The problem:
Although this attachment of child-parent works for the client’s respective player-weapon, it does not seem to attach the two for other client’s player-weapopn relationship. It works just fine if weapon is already a child in the prefab, but I’m trying to avoid this.

Here is a link to the youtube video visualizing the problem: http://www.youtube.com/watch?v=EDXLo63QNGM&feature=youtu.be

Opening a client and playing through the editor, you can see that the editor’s player-weapon are attached. When the other client joins, the weapon is not attached in any way; even though it is attached to the clients player object with it’s own Photon View transformation component. It should be moving, it was instantiated on the photon network and attached to the player. Very odd.

I’ve looked at some similar issues but the threads either died or were never resolved.

Things I’ve tried:

  • Make the weapon a child of the player
    in the prefab : works, not what I
    want though.
  • Make a separate moving script for the
    weapon similar to player : works, not
    exactly efficient or desired.
  • Making the photon view point to
    different things; i.e. transforms, a
    lerp script. Neither fix issue.
    Although the player is using this
    Lerp script and it works as seen in
    the video.

some research of similar issues but not quite:

http://answers.unity3d.com/questions/534313/text-name-above-players-head-in-photon.html

http://answers.unity3d.com/questions/312665/networkinstantiate-problem.html

Any tips, info, or potential solutions would be greatly appreciated!
Thank you.

I’ve figured out a solution. It was a matter of ensuring all clients attach the said object with a photon view to the character. Although this solution doesn’t answer my question directly, it will work for now.