Hey guys, I have made this script for my game. Basically it stops the bone from rotating too high and too low. It works which is a start but when I hit the angle specified, it jitters going back and forward. I know why it does this because I am saying if it is higher than this value, snap to that value. I am just wondering what I could do in order to make it stop when it hits the angle specified and not jitter, but when I want to move down, the bone moves again. Here is what I have so far:
var spine : Transform;
var rotateSpeed : int = 18;
function Update()
{
if (gunAiming.aimMode == 1 || gunAiming.aimMode == 0)
{
spine.transform.Rotate(Vector3(0, 0, Input.GetAxis("Mouse Y")) * Time.deltaTime * rotateSpeed);
}
if (spine.transform.rotation.eulerAngles.z > 294)
{
Debug.Log("294");
spine.transform.rotation.eulerAngles.z = 294;
}
if (spine.transform.rotation.eulerAngles.z < 244)
{
Debug.Log("244");
spine.transform.rotation.eulerAngles.z = 244;
}
}