I am doing this tutorial on making a sphere on a long rectangle jump by pressing the W key, and I can roll the ball using A or D. This is the 2nd time I’ve followed one of this guys tutorials which produce console errors for me and not for him. Here is a screenshot of his code on youtube:
And here is my code, followed by the Unity console error:
#pragma strict
var rotationSpeed = 100;
var jumpHeight = 8;
private var isFalling = false;
function Update ()
(
//handle ball rotation
var rotation : float = Input.GetAxis ("Horizontal") * rotationSpeed;
rotation *= Time.deltaTime;
rigidbody.AddRelativeTorque (Vector3.back * rotation);
if (Input.GetKeyDown(KeyCode.W))
(
rigidbody.velocity.y = jumpHeight;
)
)
And error:
What gives???