- Home /
Question by
kingmatt2 · Jan 09, 2015 at 05:41 AM ·
javascriptinputjumpscriptingbasicsdebug.log
Why doesn't this do anything?
I'm trying to get a hang of the basics, I know Lua really well and I was hoping to use what I've learned there to help me learn Java script, (or in this case Unity Script).
So what I plan to do first is a simple 2D game where you roll along on a flat ground, jump to dodge rocks. Simple. So my first step to my grand and magnificent game that is sure to make me millions of dollars, is to figure out how to jump.
I have this so far and nothing happens:
#pragma strict
var jump : bool = false;
function Start () {
}
function FixedUpdate () {
if (Input.GetKeyDown(KeyCode.Space)) {
jump = true;
}
}
function Update () {
if (jump) {
Debug.Log('Jump!');
jump=false;
}
}
Comment
Does it debug anthing inside the debug area/console? Also, why are you typing this inside FixedUpdate and not Update?
Answer by shriya · Jan 09, 2015 at 07:29 AM
Problem with your script is Bool replace it with boolean
var jump : boolean = false;
and it will work.
In Javascript its boolean and in c# its bool. Good Luck!