- Home /
End game with certain amount of points with distance
I am making a mini golf game, and when the ball moves a certain distance, it gets points. How would i make it so when it hits a certain amount of points that it would load an either game over scene, or a you win scene? (If over 130 points, lose. If under 120 when it reaches the hole, win) Thank you!
Answer by Legend_Bacon · Jan 15, 2018 at 07:23 PM
Hello there,
Loading scenes has changed a bit, but now THIS is how you do it: First add using UnityEngine.SceneManagement;
to the top of your script.
Then, do your check in a similar fashion as this:
if (points > 130)
SceneManager.LoadScene("LossScene");
else if(points < 120)
SceneManager.LoadScene("WinScene");
Note that nothing happens if the points are between 120 and 130 right now.
Hope that helps!
Cheers,
~LegendBacon
You also need to setup your scenes beforehand. I believe THIS can help you.
Your answer
Follow this Question
Related Questions
How can I generate a random number at scene start. 1 Answer
Unity Editors crashes after using a button in scene 2 Answers
Bullets follow the ship in 2D Space Shooter game 2 Answers
Coins not updating after making shop transactions 0 Answers
How can i find loudness of microphone from code? (code not working) 2 Answers