Quantcast
Channel: Questions in topic: "error"
Viewing all articles
Browse latest Browse all 7934

Can someone review a short script and tell me where I've gone wrong? [JavaScript]

$
0
0
I have began coding a controller for a 2D game and I am having a few issues. Could anyone help me out please! ![alt text][1] [1]: http://gyazo.com/d33e78f90d1cf2dff3e28a2760efdc5a.png Code #pragma strict var moveUp : KeyCode; var moveDown : KeyCode; var moveRight : KeyCode; var moveLeft : KeyCode; var speed : float = 10; var jumpHeight = 8; function Update () { if (Input.GetKey(moveUp) && isFalling == false) { rigidbody2D.velocity.y = jumpHeight; } isFalling = true; else if (Input.GetKey(moveDown)) { rigidbody2D.velocity.y = speed *-1; } else if (Input.GetKey(moveRight)) { rigidbody2D.velocity.x = speed; } else if (Input.GetKey(moveLeft)) { rigidbody2D.velocity.x = speed *-1; } else { rigidbody2D.velocity.y = 0; rigidbody2D.velocity.x = 0; } }

Viewing all articles
Browse latest Browse all 7934

Trending Articles