I'm writting a really basic character controller, and almost so far so good. But my camera movement script has some issue with rotation. From time to time when moving around, the rotation seems to "reset", or at least to go to the (0, 90, 0) coordinates (or whatever round value around 0, 90, 180 and their negative counterpart).
I'm using a basic script :
private void CameraLook()
{
float mouseX = playerController.LookDelta.x * mouseSensitivity * Time.deltaTime;
float mouseY = playerController.LookDelta.y * mouseSensitivity * Time.deltaTime;
_rotation.y += mouseX;
_rotation.x -= mouseY;
_rotation.x = Mathf.Clamp(_rotation.x, -90f, 90f);
Quaternion targetRotation = Quaternion.Euler(_rotation.x, _rotation.y, 0);
// transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, mouseSensitivity * Time.deltaTime);
transform.rotation = targetRotation;
targetRotation = Quaternion.Euler(0, _rotation.y, 0);
// playerController.orientation.rotation = Quaternion.Slerp(playerController.orientation.rotation, targetRotation, smoothSpeed * Time.deltaTime);
playerController.orientation.rotation = targetRotation;
}
with LookDelta being the mouse value getted from the Move event in the new input system. I guess my problem is from the fact that i'm using Quaternion.Euler and that isn't really partical, but I have no other solution rn.
Thanks for your time !