Download

Slowly blend gamepad axis input to 0 when player releases joystick?

Oh, wise blueprint guru master shaman warriors… I require your help!

I’m attempting to modify the values coming from the gamepad axis input values so that when a player is hard left (position -1) or hard right (position +1) and just releases the stick (position 0) the input values slowly interpolate back to the origin. I’m using this for some menu and ui cursor control effects. An easy way to explain what I’m after might be to imagine sliding a heavy object across a table. Right now, as soon as you were to remove your hand from the object (ie release the joystick), it immediately stops on a dime. Instead, I would like it to come to a full stop (position 0) gradually.

The tricky part of this seems to not to be choosing the interp method (timeline, finterp, etc) but setting up the logic around when and how to call that interpolation function, since it’s firing every tick.

Any ideas?

Something like this?
The X-AxisValue variable interpolates to the target value over time, lower interp speed makes it take longer to reach the target. You then use this value instead of the actual value on the input event.

2d6f5cb87f670bccae5b219654dacc150968d50a.png

Hey Mosel3y, thanks for the reply.

Two questions. For my situation, I would want to use a constant of 0 for the target, right? (I’m away from my computer this morning so I can’t test it myself).

Secondly, how would I limit this to only modify the input when going from -1 or +1 to 0? I don’t want any sort of interpolation except when that happens.

The target should be the actual axis value, as above. I think it will make more sense to you when you get a chance to try it out; if the target was 0, it would just be interpolating 0 to 0. Since X-AxisValue is 0.

You could set it to only use the interpolated value when the axis value==0. That would be equivalent to a user releasing the joystick - the actual axis value is 0 - so it uses the interpolated value. At all other times, i.e when the joystick is being titled - and the value is not equal to 0 - the actual axis value is used (no interpolation).

c33743970fdb4930130f8d2dc05d234f6806c137.png

Just got home and took a minute to test it out… this works beautifully! I can’t say the I really understand how this function works yet but I’m just thrilled that it does.

Thank you so much!

/bows to the great wise blueprint guru master shaman warrior Mosel3y

Hey there - this was years ago, but it would really help me out right now. I cant see the picture of the function though … cluld you please help ne here? Thanks

It’s probably just adding a lerp into the system.

I would recommend doing this instead.

Create an AxisPrev value - final thing after all the code for axis/input, has to be to save the value into the variable.
Compile save, set default to 0.

Branch.
Bool for Axis value ==0.

When true, check prev axis value. If value !=0 > lerp from the value it was to 0.

When false, the input is being used, so you want to probably reconnect whatever movement system you were using.

From the lerp, you probably also want to copy the movement nodes and apply the input over a number of seconds via a timeline.
Matching value of the lerp.

The axis input will stop firing immidiately if the prev value is 0 and the current value is 0. Based on the branch.

Or. You can do this too, because axis input always fires, sort of like on tick.
Alter the branch statement you just always allow the movement input to be added when prev is NOT 0 and current is 0.
Adding 0 won’t move you. So it’s a viable result.
The Lerp values will be overwrittren however - so for prev you have to save the result of the lerp in this case, instead of the actual axis value.
And you just lerp between prev and 0.
Then again, lerp may not be a good idea here either. You could just subtract a .1 or a .2 from the value until it reaches 0 manually.

As I said, the code will be running over and over into here every frame until the 2 values are both 0.

1 Like

Wow - that was really fast - i actually didnt expect any reaction after 7!!! YEARS… Thank you so much - i will check that tomorrow … first i should sleep a bit :blush:… have a great night and thanks again!!

1 Like