Add New Game Object To Existing Photon View

Options
zaki
zaki
Hello,

Is it possible to add a game object (as a child) to an existing Photon View game object?

Something like this:

MyPUNManager.cs
var player = PhotonNetwork.Instantiate (playerAvatar.name, trans.position, trans.rotation, 0);

And the in playerAvatar attached a player script player.cs

player.cs
GameObject childObjectToAttach; 
void Awake() {
    if(!photonView.isMIne) return;

    childObjectToAttach = GameObject.FindGameObjectWithTag ("PlayerChild");
    childObjectToAttach.transform.parent = transform;
}
If I attached the childObject like that, will the position and rotation auto-sync?

Want I want to do is, after Instanstiate player through PhotonNetwork function, i want to attached an existing game object to it and sync its position and rotation across the network.

Please advise, thanks.

Comments

  • zaki
    Options
    Hello, anyone?
  • RotemPhoton
    Options
    Hey,
    someone?
  • S_Oliver
    S_Oliver ✭✭✭
    Options
    does it have a photon view attached?

    But I don't think it will be synced if u just child it.
    Try to add a photonview to sync position and rotrotation.
    If you attach a PhotonView and leave these OBject's in the scwne it will be a sceneObject and controlled by the MasterClient so every other client has to request the ownership to sync it.