My script keeps getting these two errors.

Hey. I just started using Unity and when I typed in mono development, an error keeps on popping up. The command I typed in was,

1 #pragma strict


3 var rotationSpeed = 100;


5 function Update ()

6 {

7 var rotaton : float = Input.GetAxis (“Horizontal”) * rotationSpeed;

8 rotation *= Time.deltaTime;

9 rigidbody.AddRelativeTorque (Vector3.back * rotation);

10 }

And when I go back to play the action in Unity, the errors

Assets/BallControlls.js(8,9): BCE0005: Unknown identifier: ‘rotation’

Assets/BallControls.js(9,19): BCE0019: ‘AddRelativeTorque’ is not a member of ‘UnityEngine.Component’.

pops up and I can’t find a way to fix it.

In order to access ‘AddRelativeTorque’, it must be within context, or be able to be “seen” by the rest of your code.

For your first error, when declaring your variable you have a typo, ‘rotaton’ as opposed to original intent, ‘rotation.’

For your second error, like referred to earlier, your ‘AddRelativeTorque’ is not within context. Recently, the way we have accessed components within Unity3D has been changed, so for any component you wish to bring into context, you must use: GetComponent(). In your case the line would be:


Good luck with your future development!