- Home /
End Game on trigger,End game screen appear on Trigger
How do i code something in C# that, when my character steps on to a cube he triggers an End game scene that also loads a main menu option. I have tried googling and unity forums, but nothing seems to work.i have this but i was playing around with only the first half of the question. any help would be appreciated ,I need help with making A 'End game' screen appear. When i step on to a cube, i want the game to end. The code im trying to use
void OnTriggerEnter() Application.LoadLevel("Menu")
What exactly do you want? Do you want the game to end and then load the menu scene and what exactly do you mean by game to end like to reset some variables or direct jumping to other scene?
When the character steps on the cube i want the game to end with a game over text and a menu
Answer by KittenSnipes · Jan 20, 2018 at 11:21 PM
That is really easy although I would think you might want to make a tag for your cube. Then use the OnTriggerEnter() function.
So something like this:
void OnTriggerEnter(Collider other) {
if (other.transform.tag == "EndPlatform") {
SceneManager.LoadLevel("Menu");
}
}
'Scene$$anonymous$$anager' does not contain a definition for 'LoadLevel'
This pops up when trying to add in the code
@Drewbear90 oops I meant LoadScene("$$anonymous$$enu");
I am not entirely sure what im doing wrong. When i add the script to the cube nothing happens.
I will send you a video of how to set it up
@$$anonymous$$rsloth2004
You need using UnityEngine.Scene$$anonymous$$anagement;
at the top of your script
Answer by Drewbear90 · Jan 21, 2018 at 01:31 AM
It works thank you so much for everything!
No problem but you told me it is moving your platform? Need help with that?
No i got it fixed so all is working perfectly thank you!
Your answer
Follow this Question
Related Questions
Lighting changes when i change scenes 0 Answers
GameOver: Scene vs UI 1 Answer
Gameover On Collision 1 Answer
Game Over Canvas not showing 1 Answer
Is it possible to Play videos on a cube? 0 Answers