hi! i make fps game. I have a problem. I need to make a spawn shield but I can't do anything. I have a player on the disabled object, "the shield". I need to turn it on, when a player appears for 3 seconds. I did everything: timer function enable, rpc. but one question: when performing rpc, I have to find the scene object with the player, but I don't know how. so I tried to do this:
IEnumerator stime()
{
shiled = 4;
while(shiled > 0)
{
shiled--;
ens ();
yield return new WaitForSeconds(1);
}
dis();
}
ens void()
{
photonView.RPC ("ensh", PhotonTargets.Others, PhotonNetwork.playerName);
}
void dis()
{
photonView.RPC ("dish", PhotonTargets.Others, PhotonNetwork.playerName);
}
[PunRPC]
void ensh(string name)
{
tar = GameObject.Find (name);
//Debug.Log (name);
star = tar.gameObject.transform.GetChild (4).gameObject;
//star = name.transform.GetChild (4).gameObject;
star.SetActive (true);
}
[PunRPC]
void dish(string name)
{
tar = GameObject.Find (name);
star = tar.gameObject.transform.GetChild (4).gameObject;
//star = name.transform.GetChild (4).gameObject;
star.SetActive (false);
}
he gave the name of the player. in the scene the player object with the same name as the name in the photon
IEnumerator stime()
{
shiled = 4;
while(shiled > 0)
{
shiled--;
ens ();
yield return new WaitForSeconds(1);
}
dis();
}
ens void()
{
photonView.RPC ("ensh", PhotonTargets.Others, PhotonNetwork.playerName);
}
void dis()
{
photonView.RPC ("dish", PhotonTargets.Others, PhotonNetwork.playerName);
}
[PunRPC]
void ensh(string name)
{
tar = GameObject.Find (name);
//Debug.Log (name);
star = tar.gameObject.transform.GetChild (4).gameObject;
//star = name.transform.GetChild (4).gameObject;
star.SetActive (true);
}
[PunRPC]
void dish(string name)
{
tar = GameObject.Find (name);
star = tar.gameObject.transform.GetChild (4).gameObject;
//star = name.transform.GetChild (4).gameObject;
star.SetActive (false);
}
he gave the name of the player. in the scene the player object with the same name as the name in the photon