How to smooth with New Input System

During this lesson, you may have been using the New Input System for practice and noticed that your ship rotates by the frame, and not smoothly like Rick’s.

This is simply because, on Keyboards, the old input system has built-in smoothing to its axes. Based on settings, input would work its way from 0 to 1.

In the new input system, base Keyboard inputs can either be 0 or 1. There is no in-between.

So, here is the video that I watched to fix this problem, but I’ll try and show how I implemented it into this project.

First, you need a Serialized float called smoothInputSpeed. I set it to be .1 at base. You’ll also want two Vector2s. One called currentInputVector and one called smoothInputVelocity.
Capture

Next, you’ll probably want to make a local Vector2 somewhere that’s hit with your update function. I put it in its own method called SmoothController. I called the local Vector2throw_, and it’s equal to the Vector2 from our movement input action. Then, we want to set our currentInputVector to equal a Vector2.SmoothDamp, with the current position being our currentInputVector, the destination being our throw_ variable, with a reference to our smoothInputVelocity and finished off with our smoothInputSpeed.

After that, set your xThrow and yThrow to the x and y of the currentInputVector respectively.

After that, if you’ve been following thus far, it should be smooth sailing. The rest of my programming is pretty identical to Rick’s, adjusted for the new input system. Adjust your smoothInputSpeed in the inspector and you are good to go.

6 Likes

@ZayJayPlays man you are a life saver, thank you for this simple and elegant solution!!! Waaay cleaner than the lerp approach.

Just a note for the more distracted folks like me:

  • Don’t forget to call SmoothController() in your Update method, before calling to ProcessTranslation() and ProcessRotation().
  • Remember to remove xThrow and yThrow assignments in ProcessTranslation() method (those value are now assigned in the new SmoothController method).
1 Like

I also decided to stick with the New input system and was similarly confused. I noticed rotation was smooth with a controller but much jerkier with the keyboard than in the lecture video. Thanks so much for the fix! I can’t say I understand the code, but it works!

1 Like

Wow! Thanks! I was wondering where I went wrong this whole time!

Thanks! I totally missed those parts.

Thanks, great job.

thanks a lot help me

Absolute legend!

Huge help, thanks! Between your explanation, the linked video, and the API I was able to understand how it works too which is the most important part to me. Thanks again!

Privacy & Terms