Im having a bit of a problem restricting the rotation of my character i only want the character to have a rotation of 0,90,180 and -90 my script looks like this
var Distance = Vector3.Distance(target.position,transform.position);
var Angle = transform.rotation.eulerAngles.y;
if(Angle > Rotation90){
Angle = Rotation90;
}
else if(Angle < RotationMinus90){
Angle = RotationMinus90;
}
else if(Angle > Rotation180){
Angle = Rotation180;
}
else if(Angle > Rotation00){
Angle = Rotation00;
}
if(ZombieMove)
{
Debug.Log(Angle);
//Debug.Log(Distance);
transform.rotation.eulerAngles = new Vector3( 0, Angle, 0 );
transform.LookAt(target);
transform.position += transform.forward*MoveSpeed*Time.deltaTime;
when i play it the zombie just looks at the character even if its none of the clamped rotations what do i need for it to only use the 90,-90,180 and 0?