This script was made to compare player tags and determine if they are active (clones) and select an active clone and rename Rplayer to random players name. But It seems to get stuck on the second random select if a player isn't active. I receive Debug.log (Rplayer 2) Debug.Log (Player tag 1) I have tried swapping it around so it's if (! = null) and rebuilding the code but still no luck same thing. Any Ideas? I feel like I'm just looking at this wrong.
if (player.CompareTag("Player1"))
{
Rplayer = Random.Range(1, 4);
if (Rplayer == 1)
{
rplayer1 = GameObject.FindWithTag("Player2");
Debug.Log("Rplayer 1");
}
else if (Rplayer == 2)
{
if (GameObject.FindGameObjectsWithTag("Player3") == null)
{
Rplayer = Random.Range(1, 3);
if (Rplayer == 1)
{
rplayer1 = GameObject.FindWithTag("Player2");
}
else if (Rplayer == 2)
{
if (GameObject.FindGameObjectsWithTag("Player4") == null)
{
rplayer1 = GameObject.FindWithTag("Player2");
}
else
{
rplayer1 = GameObject.FindWithTag("Player4");
}
}
}
else
{
rplayer1 = GameObject.FindWithTag("Player3");
}
Debug.Log("Rplayer 2");
}
else if (Rplayer == 3)
{
if (GameObject.FindGameObjectsWithTag("Player4") == null)
{
Rplayer = Random.Range(1, 3);
if (Rplayer == 1)
{
rplayer1 = GameObject.FindWithTag("Player2");
}
else if (Rplayer == 2)
{
if (GameObject.FindGameObjectsWithTag("Player3") == null)
{
rplayer1 = GameObject.FindWithTag("Player2");
}
else
{
rplayer1 = GameObject.FindWithTag("Player3");
}
}
}
else
{
rplayer1 = GameObject.FindWithTag("Player4");
}
Debug.Log("Rplayer 3");
}
Debug.Log("player tag 1");
}
Aucun commentaire:
Enregistrer un commentaire