//Textures for direction change
var leftTexture : Texture;
var rightTexture : Texture;
function Update () {
//Change texture
if(Input.GetButtonDown("A")){
renderer.material.mainTexture = leftTexture;
}
if(Input.GetButtonDown("D")){
renderer.material.mainTexture = rightTexture;
}
}
//Controls
var moveSpeed = 10;
function FixedUpdate () {
if(Input.GetAxis("W")){
Rigidbody.AddForce(Vector3.forward * - moveSpeed);
}
}
That’s my code for trying to move my player with a Rigidbody. I get this error:
Assets/Standard Assets/Scripts/My Scripts/Character.js(24,19): BCE0020: An instance of type ‘UnityEngine.Rigidbody’ is required to access non static member ‘AddForce’.
The Player does in fact have a rigidbody. ideas?