i have a gun turret on a car that i aim with the mouse i want to be able to restrict the rotation of the turret to the front as if i move the mouse too far it points into the car
this gets the gun to look at the mouse pointer.
var lookTarget : Vector3;
function Update()
{
var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
var hit : RaycastHit;
if (Physics.Raycast (ray, hit))
{
lookTarget = hit.point;
}
transform.LookAt(lookTarget);
}
how can i set it so it can only pivot in a say 90 degree cone.