Smoothing Joysticks Movements

Hey all,

I am looking for a way to smooth a joystick movement, a very basic one:

I want to have a smoothing curve for when the user starts/ends the joystick action, so it’s not abrupt.

I looked so much online and found lots of random ideas but none worked,
From FINTERP to adding a Curve table, I was not able to get it done.

Is there a known solution that I’m missing?

Thanks a lot.

Hello,

I would recommend to do the movement in Tick, and just store a target move rate when input triggers.
You also want to scale your move rate by the delta time before applying it, to reduce the effect of frame rate.

Try something like this (adjust your -50 as required, it should be the desired cm/sec):

You could also use a curve, various ways to go about that but I would use a very similar solution to the above, remove the scaling in the input trigger (so target is -1 → 1, and define your curve over the same range and with values also in that range), change FInterpTo to FInterpToConstant and reduce the Interp rate (significantly, to a small fraction of 1) and after the FInterpToConstant evaluate your curve and multiply that by your desired move rate and the time delta.

Hey,

Thank you for the graph!

I tried it like you suggested:

But currently if I start moving the joystick, it starts to add values but doesn’t stop, even if I stop touching the joystick.

I tried amping the -50 to even -500 but it’s not making a big difference.

I also tried reducing intrp speed to 5-1, no change.

It’s kind of adding value smoothly but doesn’t stop so the movement goes on and on.

What did I do wrong?

Thanks again

Hi, sorry that’s my fault: this was always going to happen with a default setup for the input action and hooked up only to Triggered

Two solutions:

Without changing the Input Action, you can wire the event up to Started and Completed instead of Triggered:

Or, leave the event alone and add explicit triggers to your Input Action:

Nice fix! Thank you.

The first way (started/completed) works better it seems, the second one glitches a bit.

I do notice though that in this setup, the speed of the movement is fixed.
So if I move the joystick quickly to one direction, it will move fast, but it won’t slow down if I move it to 50% or so. If I start moving it slowly, it will move slow but won’t speed up if I boost it to 100%.

I understand why it’s behaving this way but not sure how to keep the movement sensitivity.

My bad again :slight_smile: Using Started and Completed we are only capturing the first value we see and then resetting to 0 when there is no input. So we fixed one problem and introduced another (not updating anymore as the input varies), hook it back up to Triggered, and disconnect the Started if you like (won’t matter either way, but isn’t needed with Triggered back in the mix).
:crossed_fingers:

Amazing! that makes sense and works perfectly.

Thank you so much :slight_smile:

Does it mean that every value I want to smooth this way, needs 2 extra variables for this process?
I am wondering if there’s a shortcut, since I have about 10 places with this setup and each one has 3 joystick controls.

No worries, glad it is working as yo wish :slight_smile:

Probably can’t help streamline though, no simpler way comes to mind. You could wrap the functionality up in some reusable object, but there is nothing in Blueprint that allows functionality and is sufficiently lightweight to recommend. In C++ a struct would do fine, unfortunately structs in BP can not have functionality so you would be forced to use either objects or components, which are very heavy handed solutions for what we doing here.

Thank you !

UE has weird limitations (for example the inability to duplicate multiple variables across blueprints)

So add 20 new variables across 10 blueprints and it might take forever :slight_smile: though the result is definitely worth it and is very smooth!

many many thanks again

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.