I used an old tutorial on how to make a ball rolling game. Mine will not work. IT says there is an error with the rigidbody line. Thanks!.
#pragma strict
var rotationSpeed = 100;
function Update ()
{
var rotation : float = Input.GetAxis (“Horizontal”) * rotationSpeed;
rotation *= Time.deltaTime;
rigidbody.AddRelativeTorque (Vector3.back * rotation);
}
First of all, you should add a RigidBody component to your GameObject. After that, you need to refer to that component, otherwise the game will not know, which RigidBody should get the force you are adding.
var rotationSpeed = 100;
var rb: RigidBody;
function Start()
{
rb = GetComponent(RigidBody) as RigidBody;
}
function Update()
{
var rotation : float = Input.GetAxis ("Horizontal") * rotationSpeed * Time.deltaTime;
rb.AddRelativeTorque (Vector3.back * rotation);
}