[SOLVED] Adding lives system, but can't reset the ball

I have finished the Block Breaker section and am trying to implement a lives system in my game. I have managed to make the lives work, in that when I play a level the lose screen does not load which would indicate that the player still has lives left, but I can’t seem to make the ball reset.

Here is my code for the lose collider. The highlighted section is where I am checking for lives and trying to reset the ball.

I am still very new at C# and honestly don’t know what I did wrong. How can I make the ball reset, so that the player can try again without having to start over? Any help would be appreciated. Thanks in advance.

Hello @Mary_Hale :), I did it by using this code

//Return the ball to the paddle current position
ball = GameObject.FindObjectOfType<Ball>();
paddle = GameObject.FindObjectOfType<Paddle>();
livesNumber = GameObject.Find("Lives number").GetComponent<Text>();
livesNumber.text = LoseCollider.lives.ToString();
ball.hasStarted = false;
ball.transform.position = new Vector3(paddle.transform.position.x, 1.343f);

Privacy & Terms