- Home /
input question
hi im trying to add an exit on my game.
i have this script on an empty so that when he hits space he goes back to a main menu scene i added the name of the level in the inspector and have it under the game build.
doesnt work though.
#pragma strict
var levelToLoad:String;
function Start () {
}
function update () {
if(Input.GetButtonUp("Jump")){
yield new WaitForSeconds(0.1);
Application.LoadLevel (levelToLoad);
}
}
Answer by Olgo · Jan 18, 2013 at 08:10 PM
That should work... I do seem to have issues with yield though sometimes.
Why do you need to wait .1 seconds?
you could implement another sort of timer using Time.deltaTime.
Also, is your "Jump" set to be space bar?
yes it is set to jump. will try removing yield. ill update
another thing, what is your levelToLoad string set to? Is it equal to the name of the scene you want to load? that is important too. Can't tell just from this snippet of code though.
Your answer
Follow this Question
Related Questions
Disabling UI Input on a per player basis 1 Answer
Game Menus WIth Keyboard Input Control 1 Answer
Deactivate UI windows in order when "Escape" button is pressed. 1 Answer
Can I make a script run BEFORE a UI Button gets input? 1 Answer
Gamepad menu navigation with uGUI not working as expected. 1 Answer