Quantcast
Channel: Photon Unity Networking (PUN) — Photon Engine
Viewing all articles
Browse latest Browse all 8947

Add New Game Object To Existing Photon View

$
0
0
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.

Viewing all articles
Browse latest Browse all 8947

Trending Articles