How to make the game end when you touch and object
I am trying to make a small game where you are in a maze and you have to find an object. I want to make it so you can touch or bump into the object and the game will go into the new scene that has just text saying congratulations.... So how do i get the game to end and enter ending scene when i touch the object and how do i make a scene with just text Thanks
Answer by TheMrAngel · Mar 11, 2016 at 11:21 AM
For jumping into another scene when you touch the object, first you have to attach a Button component to that object and an script. In the script just add:
void OnClick() {
Application.LoadScene("NameOfTheScene");
}
And the game will load the scene called "NameOfTheScene" (or whatever) when you click or touch the object.
You have to create that scene with the same name and put inside whatever the Text you want (New -> UI -> Text).
You are using outdated code.
At the top of the script put
using UnityEngine.Scene$$anonymous$$anagement;
and ins$$anonymous$$d of
Application.LoadScene("NameOfTheScene");
put
Scene$$anonymous$$anager.LoadScene("NameOfTheScene");
Your answer
Follow this Question
Related Questions
flip view,half window display 0 Answers
Is there a way to make an Object pass over a Text? 0 Answers
Play mode enables objects 0 Answers
How to i view all my object? 0 Answers
One JSON file, multiple objects, multiple scenes... 0 Answers