IEnumerator Spawn() { Spawning = true; animator.SetBool("Death", true); gameObject.GetComponent <Rigidbody2D>().velocity = new Vector2(0, 0); gameObject.GetComponent <Rigidbody2D>().rotation = 0; ballLives--; healthBar.SetHealth(ballLives); yield return(new WaitForSeconds(1f)); if (ballLives != 0) { transform.position = spawnPoint; animator.SetBool("Death", false); } else { Instantiate(restart, transform.position, Quaternion.identity, canvas.transform); Destroy(gameObject); hitText.Lose(); } Spawning = false; }