How do I achieve "inertial" camera movement for mouse look?
I stumbled upon a way to use .Lerp for camera look which makes it feel intertial. In short, it looks like this:
yaw += Input.GetAxis("Mouse X") * mouseSensitivity;
pitch -= Input.GetAxis("Mouse Y") * mouseSensitivity;
pitch = Mathf.Clamp(pitch, -maxLookAngleY, maxLookAngleY);
camera.transform.localRotation = Quaternion.Lerp(camera.transform.localRotation, Quaternion.Euler(pitch, yaw, 0), Time.deltaTime * mouseSensitivity);
Now, I know you are not supposed to use Lerp like this, but it gives mouse look a great "inertial" heavy feeling to it (the movement isn't instant and is delayed, when you stop moving mouse the movement continues for some time).
I would like to reproduce this in some other way (or fix the current way), because as of now it sometimes "jumps" to the direction that is the opposite from current rotation at seemingly random times.
Any ideas?
Answer by wew_wew · Feb 28 at 10:19 PM
After some experiments I think I figured the cause of the problem but am not quite sure how to go around it. I think what is happening is that since "current" (actual) rotation angle is delayed compared to "target" rotation, when you move the mouse there are points at which target angle goes say from -179 to +179 and therefore the direction of "current" actual rotation changes.
Your answer
Follow this Question
Related Questions
Lerp between two direction vector 0 Answers
How to move a camera smoothly to a fixed position and back using C#? 0 Answers
Lerp with Coroutine doesn't behave as expected 0 Answers
Lerp Doesn't Work On Mobile 1 Answer
Lerp Problem 1 Answer