- Home /
Mouse look with Slerp
I'm having trouble with using Slerp. I want to control where the camera looks using the mouse (like with FPS controls) but I wanted a smooth and gradual motion when moving the mouse around, so I decided to use Quaternion.Slerp. The problem is it sometimes goes the opposite way of where I intended, I assume, because of how the algorithm was implemented. Does anyone know how to circumvent this?
Here's my code:
cummulativeRotation.x -= Input.GetAxis("Mouse Y") * Time.deltaTime * rotationFactor; cummulativeRotation.y += Input.GetAxis("Mouse X") * Time.deltaTime * rotationFactor;
if (Mathf.Abs(cummulativeRotation.x) > 90) cummulativeRotation.x -= cummulativeRotation.x%90;
Quaternion targetRotation = Quaternion.Euler(cummulativeRotation.x, cummulativeRotation.y, 0.0f); currentRotation = Quaternion.Slerp(currentRotation, targetRotation, ROTATION_DAMP * Time.deltaTime);
Your answer
Follow this Question
Related Questions
Slerp/Rotational Problem Query 1 Answer
Rotation always changing values! 1 Answer
when mouse is on a object do this 2 Answers
How to prevent objects from going through each other when using mouse? 1 Answer
Rotate and Move towards Mouse Point 0 Answers