Changing scene by pressing a key
Hiya! So I'm working on a game completely on my own. I'm not good at all with unity or coding. So my problem is that I want to stand in a cartain area and press a button, which then switches scenes to where you can buy guns (other scene). My code atm looks like this
void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag == "Player")
{
ContinueText.text = Continue;
helpText.text = "";
}
if (Input.GetButtonDown("Use"))
{
Application.LoadLevel("Shop");
Debug.Log("Loading level: Shop");
}
I added "Use" to the input manager aswell. Anyone knows what I can do to make it work? Atm I don't get any errors.
Answer by TrustEditz · Dec 02, 2016 at 10:35 AM
If anyone is googling and comes to this topic, the answer was in the function. Instead of using OnTriggerEnter, which only runs when you enter the object. Use OnTriggerStay, which runs as long as you're inside the trigger
Answer by usalalas · Dec 19, 2015 at 12:30 PM
Did you add a breakpoint on line 10 to see if the debugg stops there?
Don't understand what you mean. Care to show me what you mean?
Well, In $$anonymous$$onodevelop you can add a breakpoint to that line, to see if the script enters there.
I'm not used to Visual Studio, but you should be sure that this line is been executed. That's why I asked about the breakpoint.
Yeeeeah, tried it, don't get a notification, even on line of code that runs
Your answer
Follow this Question
Related Questions
Standalone build rotation shuddering with input button 0 Answers
Windows Phone 8.1 crash when loading first scene 0 Answers
Switch Statement Gives Error PLEASE HELP!!! 2 Answers
Calling GetButtonDown on an input axis 1 Answer
I need help getting a sound to play when the E Key is pressed. (E will also load a new Scene). 2 Answers