How to make a game of Pong end once the score reaches 10? (C#)

In the game that I am making (Pong remake) I already have a counter for the points and once the score reaches ten it says You Win! however the ball keeps moving and the points keep being counted, and once the score reaches eleven the You Win! goes away.

What I am trying to do is make the game return the ball to the origin, stop it from moving, say You Win!, and give the option to Return to Menu or Play Again.

Here is my code

		if (PlayerScore1 == 10) {
			GUI.Label (new Rect (Screen.width / 2 - 150, 200, 2000, 1000), "AI WINS");
			theBall.gameObject.SendMessage("hasWon",null,SendMessageOptions.RequireReceiver);
			Application.LoadLevel("MainMenu");

As you can see I tried to make the new buttons and such in a different scene but it doesn’t change ever.

Any help is appreciated! Thank you in advance.

Never mind guys i figured it out by my self(with the help of many google searches) I will mark this question solved!

Good job of finding solution to your problem by yourself. :-) You might also want to put your solution here as an answer for future visitors of this question to get an idea of how it was solved. It might help someone in future.

Is MainMenu added to your build settings?

2 Answers

2

Hi.What you chould do is after the game is over to pause the whole game and just add some buttons.
To pause the game all the code you need is Time.timescale = 0.0f;

the code I had worked I just didn’t have the Ball tagged as a Ball…

Mark this as answered then.