- Home /
Question by
danielread89 · Feb 03, 2012 at 07:14 AM ·
javascriptnoob
Extreme Beginner Scripting Question
Hey, I am very very new to both Unity and Javascript so please bear with me with how simple my question is.
I am just trying to figure out the basics of how this works so I want a "cube" object i created to move up a little when I press the "Space" button.
I came up with this so far (my understanding is noted with // so whoever will respond can tell me if im correct)
function Update () { //every moment
if (Input.GetButtonDown("Jump")) //if Space bar is pressed down
transform.position = Vector3.up; //move the position of the object up along the z axis
}
obviously it doesn't work any help is very appreciated
Comment
Answer by tianjishu · Feb 03, 2012 at 08:34 AM
function Update () { //every moment
if (Input.GetButtonDown("Jump")) //if Space bar is pressed down
transform.position += transform.up * distance; //move the position of the object up along the z axis
}