What i want in this script i made is that my object which is a tire, needs to rotate the to side when pressing “a”.
When it then hits 16 if(transform.rotation.z > 16)
Then it stops. transform.rotation.z = 16;
But somehow it continues to rotate and doesn’t stop at 16.
If you have any questions, ill answer them.
#pragma strict
var speed : float;
var turnSpeed = 0.0;
var turnMotion = 0;
function Start () {
}
function Update () {
speed = gameObject.Find("Rubber").GetComponent(Movement).speed;
transform.Rotate(Vector3(turnSpeed,0,0) * Time.deltaTime);
turnSpeed = speed * 20;
if(transform.rotation.z > 16) {
transform.rotation.z = 16; }
if(Input.GetKey("a")) {
transform.Rotate(Vector3(0,0,turnMotion) * Time.deltaTime);
}
}