Hi,
I’m using Random.Range to play one of 8 death animations randomly when the bool that checks if the player has died becomes true. It works, but it seems like it’s always the first 4 animations that are played and rarely, it even doesn’t play any of the death animations. Here’s my code:
void Start()
{
rand = Random.Range(1, 8);
_animator = GetComponent<Animator>();
dead = false;
}
void Update()
{
if (h.dead1True)
{
if (photonView.isMine)
{
StartCoroutine(WaitdeathPlane());
}
if (rand == 1)
{
hipshakeDeath = true;
//xploDeath = false;
}
if (rand == 2)
{
//dead = false;
xploDeath = true;
}
if (rand == 3)
{
headSlapDeath = true;
//xploDeath = false;
}
if (rand == 4)
{
//dead = false;
crouchDeath = true;
}
if (rand == 5)
{
saluteDeath = true;
//xploDeath = false;
}
if (rand == 6)
{
//dead = false;
dead = true;
}
if (rand == 7)
{
sprald = true;
//xploDeath = false;
}
if (rand == 8)
{
dance = true;
//xploDeath = false;
}
Is there a better way to make this work every time and to be sure that the random range choose between all 8 animations instead of just the same four that it seems it’s choosing?