Does CharacterController benefit from adding lerp?

as in this script.

mouse = Input.GetAxis("Mouse X");
current = Mathf.Lerp(current, mouse, Time.deltaTime * 10);
transform.Rotate(0, current * 600 * Time.deltaTime, 0);

I was using,

transform.Rotate(0, mouse * 18, 0);

But read into the idea of lerp and wrote that.

  • \$\begingroup\$ What are you trying to accomplish, and why? \$\endgroup\$
    – DMGregory
    Commented May 16, 2019 at 1:34
  • \$\begingroup\$ I saw someone say interpolation helps. So I thought this would make that regular mouse rotation more smoother or better. \$\endgroup\$ Commented May 16, 2019 at 3:43
  • \$\begingroup\$ I wanted to ask this question in the other post, because you said the * time.delta time is already used by charactercontroller. But that guy got mad and said to make a new question. \$\endgroup\$ Commented May 16, 2019 at 3:49
  • 1
    \$\begingroup\$ I spend a lot of time on this board, but I don't remember ever seeing someone get mad. Stack exchange only works if you stick to the format. Otherwise, this is just a really unintuitive forum. What DMGregory is probably trying to say is that this is a place you should come to when you're stuck. You have a goal, you've made steps to reach it, but you've hit a roadblock that you don't know how to get around. So basically, the first question you should ask yourself is "do I have a problem that needs fixing?" Choppy movement would be a problem. Did you have choppy movement without the lerp? \$\endgroup\$
    – Peethor
    Commented May 16, 2019 at 5:34
  • 1
    \$\begingroup\$ I would comment this out until getting a real problem with this and then do AB testing or actually trying and creating this problem - I am not sure about Unity3D but in UE4 it is easy to get Choppy mouse all you have to do is to enable VSync and maje your CPU code as a bottle neck - for instance put 10k random distance calculations - and then when you will get a choppy movement - take a look if lerp actually helps. \$\endgroup\$ Commented May 16, 2019 at 22:21

1 Answer 1


As a general practice, find a problem before you try to solve it.

There are lots of solutions in game development, and many of those solutions are for problems that you do not have.

Reaching for a solution before you know if there's a problem or what it is can lead to:

  • wasted work (you didn't have a problem at all, now you've spent time for no benefit)

  • sub-optimal solutions (you missed an opportunity for a better solution for your specific case)

  • creating new problems (this solution is so ill-fit for the current situation that it actually makes it worse)

The specific example you have here looks like one of the "creating new problems" variety.

Here you're taking the player's mouse input, and instead of using it to immediately turn their camera in exact proportion to their movement to make their control tight & responsive, you are adding a layer of indirection.

The variable current will seek toward mouse (at an inconsistent rate when running at different frame rates, since you used Time.deltaTime incorrectly in your third Lerp argument), but always lag behind it:

  • if I move sharply to the right, current will increase by only a fraction of my movement: I have to make an exaggeratedly large movement to get the response I intended.

  • if I keep moving to the right at a constant speed, current will gradually increase closer and closer to my actual input value, by smaller and smaller intervals each time. So to turn at a constant rate, I actually have to start moving fast then slow down my arm to avoid over-accelerating.

  • if I stop moving, current will continue to have a positive value and the camera will keep spinning for several frames. So I have to stop early and hope the camera will come to rest somewhere near where I want it.

This will tend to make your controls feel spongy, laggy, and non-responsive, or even outright sloshy and motion sickness inducing.

So no: don't do this.

Lerp isn't your "make stuff smoother" sauce. It's a math function that blends two values. First, understand what values you're working with and whether it's appropriate to blend them, before reaching to Lerp or another method.

  • \$\begingroup\$ Awesome, guess all those tutorials where wrong then,This was also much better than things I saw on google, thanks a bunch again DMGregory. \$\endgroup\$ Commented May 27, 2019 at 20:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .