Im begginer game dev and trying to synchronize SetActive(). (Im not good at English and codding terms, sorry)
-
There are 2 players in this Scene. Both players can see mesh corresponding to player1deck[0] but when i am trying to SetActive child objects in script bellow players only see thair respective meshes active but not the meshes of second player.
-
Im used PhotonNetwork.Instantiate(player1deck[0].name, new Vector3(0, -4, 0), new Quaternion(0, 180, 0, 0)); in other script.
-
In Start() im getting Array of Items from other scene (i susspect problem can be here),
then in ShowMesh() im calling SetActive() to all elements in the array (without i = 0 becouse its already active), but only i can see those meshes. (player1deck[0] is a perent of other meshes)
Hope You can understand what i was trying to say. Thanks
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
using Photon.Realtime;
public class DeckCopy : MonoBehaviour
{
public Item[] player1deck;
PhotonView view;
Transform itemPerent1;
string objectName;
public string playerInHierarchy;
void Start()
{
view = GetComponent<PhotonView>();
if (view.IsMine)
{
player1deck = Deck.instance.TransferDeck(); //Array of Items located in other scene
ShowMesh();
view.RPC("ShowMesh", RpcTarget.OthersBuffered);
}
}
[PunRPC]
void ShowMesh()
{
playerInHierarchy = player1deck[0].name + "(Clone)";
itemPerent1 = GameObject.Find(playerInHierarchy).transform;
for (int i = 1; i < 4; i++)
{
objectName = player1deck*.name;*
itemPerent1.transform.Find(objectName).gameObject.SetActive(true);
}
}
}