I wanted to make an anti-grav ship which during turning i.e left rotates itself on y-axis in the same time for about 10’ left and gets back to its default y-rotation after horiz-axis button is not pressed, and my problem is that this code i’ve made have an error that i can’t point out myself.
Here’s my error message:
(An instance of type ‘UnityEngine.Rigidbody’ is required to access non static member ‘rotation’)
Here’s the code: (updated)
var speed: float = 300.0;
var y: float = 1;
function Update() {
horRotation = Input.GetAxis ("Horizontal");
verMovement = Input.GetAxis("Vertical");
if (verMovement) {
rigidbody.AddForce(transform.forward * verMovement * speed);
}
if (horRotation){
transform.Rotate (Vector3 (0,horRotation,0));
transform.Rotate (Vector3.forward * horRotation);
transform.rotation.y = Mathf.Clamp (transform.rotation.y, -10, 10);
}
}
function LateUpdate () {
horRotation = Input.GetAxis ("Horizontal");
verMovement = Input.GetAxis("Vertical");
//rotation = transform.gameObject;
while (Rigidbody.rotation.y > 0 && !horRotation){
transform.Rotate (Vector3 (0,-y,0));
}
while (Rigidbody.rotation.y < 0 && !horRotation){
transform.Rotate (Vector3 (0,y,0));
}
}