# playMaker

### Author Topic: Advanced float lerp with custom interpolation  (Read 4665 times)

#### jeanfabre

• Hero Member
• Posts: 13432
• Official Playmaker Support
##### Advanced float lerp with custom interpolation
« on: August 06, 2014, 02:58:54 AM »
Hi,

After reading an article on Lerping, I realize how much more can be done with this then just smoothing out values.

I needed to create some exponentials for joystick input control and created this action. instead of using lerp as a linear interpolation, I inject some math on the amount of lerp you want to create effects like easein, easeout, quadratic ( expo )  or smoothness.

it assumes several hypothesis to work well. The amount of lerp has to be normalized ( between 0 and 1), BUT I have added the possibility to range from -1 to 1, so that you can inject your Input value straight away without worries and it deals with the negative values automatically.

And so typically, if you want exponential on your joystick input, use this action like this:

from float: 0
to float:1
interpolation: pick the desired effect, choose quadratic for exponential.

and boom, your input will react slowly around the center and as you go right to the max value of the joysticks it reacts faster. It's great for better and more intuitive feeling of controls ( aiming and accurate controls for flying or steering)

Bye,

Jean

#### gsmetzer

• Playmaker Newbie
• Posts: 24
##### Re: Advanced float lerp with custom interpolation
« Reply #1 on: August 06, 2014, 09:52:04 AM »
This is excellent! Thanks Jean,  Lerping really is the secret to smooth game mechanics.

#### jeanfabre

• Hero Member
• Posts: 13432
• Official Playmaker Support
##### Re: Advanced float lerp with custom interpolation
« Reply #2 on: August 08, 2014, 04:35:44 AM »
Hi,

yeah, I also increased the quadratic by multiplying several t, once is not really noticeable we found. So I'll update that action in a short while with more options.

Bye,

Jean

#### Red

• Hero Member
• Posts: 563
##### Re: Advanced float lerp with custom interpolation
« Reply #3 on: August 25, 2014, 09:08:01 AM »
Nice stuff!

I can see a lot of ways this would be helpful especially for things like giving users a finer level of control for analog-stick control setups. I can't count on my hands and feet how many times I've played a game with an analog controller and having to re-train myself to using it to get the fine control I wanted (mostly with FPS games... It's like having to really feather the stick if I only want to move the HUD a tiny bit that makes me realize why "auto-aim" is even a thing for a lot of console FPS games.)

#### jeanfabre

• Hero Member
• Posts: 13432
• Official Playmaker Support
##### Re: Advanced float lerp with custom interpolation
« Reply #4 on: September 09, 2014, 11:25:41 PM »
Hi,

yep, indeed, it was created just to address this problem, now it's de facto implemented in all my joystick based work as it gives a much better feeling around the dead zone of the joystick.

Bye,

Jean

• Full Member
• Posts: 135
##### Re: Advanced float lerp with custom interpolation
« Reply #5 on: September 13, 2014, 05:57:21 AM »
Jean, could you post an example on how to use it? I tried but I think I'm making it wrong.  I'm having problems in setting up a generic usb joypad to act as smooth as the xbox joypad. While the xbox stick raise from 0 to 1 gradually the generic stick ramps up real fast and I thought that this action could help but looks like I'm doing something wrong because it makes no difference at all if I use it or not. I talked with the guys at cInput to confirm that the problem may be with the joypad driver (it's called USB Network Driver) as I tried the same in a fresh unity project without cInput and this action and had the same result.

#### jeanfabre

• Hero Member
• Posts: 13432
• Official Playmaker Support
##### Re: Advanced float lerp with custom interpolation
« Reply #6 on: September 18, 2014, 04:47:32 AM »
Hi,

You may look at this the wrong way.

This action "smooth" out the joystick value, the best way to see if it has an effect is to compare the raw input with the processed input visually with a controlled input value.

typically, have a variable to move manually and see the effect when applying the action, you'll see that value 0 and 1 will be the same while intermediate values will vary.

Please find a link to a sample showing a very straight forward use of the LerpAdvanced action, this will show you the effect visually.

Bye,

Jean