How to Fix Rotation Snaps?

I tried to get full camera rotation by putting horizontal rotation on the right button and vertical rotation on the middle button, but because there are 0s for the other two axes the camera snaps back to the original height/direction whenever I switch from one button to the other.

How do I get smooth full camera rotation on one button?

This is the tutorial I finished when I decided to try getting 3d rotation.

private void RotateCamera(InputAction.CallbackContext obj)
{
if (!Mouse.current.middleButton.isPressed)
return;
float inputValue = obj.ReadValue().x;
transform.rotation = Quaternion.Euler(inputValue * maxRotationSpeed + transform.rotation.eulerAngles.x, 0f, 0f);
}
private void RotateCameraa(InputAction.CallbackContext obj)
{ if (!Mouse.current.rightButton.isPressed)
return;
float inputValuee = obj.ReadValue().y;
transform.rotation = Quaternion.Euler(0f, inputValuee * maxRotationSpeed + transform.rotation.eulerAngles.y, 0f);
}

8317407–1091556–CameraMovement.cs (7.04 KB)

Camera stuff is pretty tricky… you may wish to consider using Cinemachine from the Unity Package Manager.

There’s even a dedicated forum: Unity Engine - Unity Discussions

Thanks, I will! I’m just curious to see if I can salvage some value from what I have.

Excellent, I can respect that.

I see you using .eulerAngles above… they can be problematic, or at the least tricky to reason about. Allow me to gently pry open a fold of your great brain and drop this little tidbit in for your consideration:

https://starmanta.gitbooks.io/unitytipsredux/content/second-question.html