# Unstable Rotation - GameObject Begin Crazy

Hi !

I’m trying to make a cube rotate with a fixed camera. It seems to work fine from a part of the rotation (on a side) but start to be instable and crazy in certain parts of the rotation (Seems to be close to undescision angle !).

Here is my code :

``````if(Input.GetMouseButton(0))
{
mouseMove.x += Input.GetAxis("Mouse X") * moveSpeed * 0.06f;
mouseMove.y -= Input.GetAxis("Mouse Y") * moveSpeed * 0.06f;
mouseMove.y  = Mathf.Clamp(mouseMove.y, angleLimitBottom, angleLimitTop);

Quaternion rotateW = Quaternion.AngleAxis( mouseMove.x, gameObject.transform.up);
Quaternion rotateH = Quaternion.AngleAxis(-mouseMove.y, gameObject.transform.right);

transform.rotation = Quaternion.Lerp(transform.rotation, rotateW * rotateH, Time.deltaTime * zoomSpeed/12);
}
``````

The problem seems to come from Quaternion.AngleAxis, but I cannot really explain it. It more or less join my previous message about the function Quaternion.Angle which doesn’t make sens.

If someone has an idea about the instability. I would be very gratefull.

Kind Regards.

It seems to doesn’t inspirate anyone. Does someone has an other way to do this kind of stuff ?

Try to fixe the unstable stuff by fixing after the Slerp the right position, It’s a little bit less crazy but still the behaviour I’m wainting for :

``````			transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles.x, transform.rotation.eulerAngles.y, transform.rotation.eulerAngles.z);
``````

You haven’t really described what the code is supposed to do when it is working properly. Do you want to drag the object around so it rotates (like Google Earth)? If so, you might find the script in this thread useful.