Just a simple re spawn for testing death animations but I noticed when the Death Sequence is called the re spawn goes fine, but then the player is re spawned, another time, then one more. 3 in total then stops, the first is fluid and then it puts him back to the re spawn point again with like… a flicker twice then stops.
Ill insert the relevant code.
public void TakeDamage(int amount)
{ if(canGetHit == true)
{
Debug.Log("GotHit");
isAttacked = true;
currentHealth -= amount;
ani.SetTrigger("isHit");
StartCoroutine(hitKnockback());
}
if(currentHealth <= 0)
{
StartCoroutine("DeathSequence");
}
}
private IEnumerator DeathSequence()
{
ani.SetBool("IsDead", true);
canGetHit = false;
canMove = false;
yield return new WaitForSeconds(2f);
transform.position = respawnPoint.transform.position;
Debug.Log("RESPAWN");
currentHealth = maxHealth;
ani.SetBool("IsDead", false);
canGetHit = true;
canMove = true;
}