Hi, i have an object that has a z rotation that should be clamped to 45 degrees each side.
The problem is that transorm.Rotate returns nothing and im a bit stuck how to clamp it properly.
will appreciate any help.
Thanks in advance.
#pragma strict
public var speedModifier: float;
public var speed : float = 0;
var arm : armScript;
public var position : Vector3;
function Update (){
var armAngle: float = arm.angle;
if (armAngle > 0.42){
speed = -20;}
else {speed = 20;};
transform.Rotate(Vector3.back, speed * Time.deltaTime);
GetComponent.<Rigidbody2D>().velocity.x = transform.rotation.z * speedModifier;
transform.position = new Vector3
(
Mathf.Clamp (transform.position.x, -2.2,2.2), 0.0f
);
}