Player Character deceleration

I am trying to get a player character to decelerate slowly; while the ground friction affects it I still cannot get to a point where I can control the speed of deceleration, I am also not wanting to have the movement like that of an ice rink. The walking deceleration does nothing as far as I can tell.

As I am using the AddMovementInput to control the speed, how can I affect the deceleration?

Thanks in advance,

Just tagging along to see if you get an answer. But my player character seems to work ok by adjusting the acceleration/ deceleration in the defaults tab but my Ai characters accelerate as expected but stop dead when arriving at locations.

I found that lowering the ground friction to the point where I was happy with the deceleration left me with almost frictionless motion. Instead, I’ve implemented a “cooldown” effect:

When the “forward” axis becomes zero (for my test, I’ve just left it as “W released” event):

  • Determine the current speed, and work out a “speedFactor” from this by comparing it to the max speed.
  • Play a timeline going from (t=0, cooldownFactor=1) to (t=1, cooldownFactor=0). At each timeline update, take (cooldownFactor * speedFactor) and use it in an AddMovementInput call.

This works rather nicely: the faster you go, the longer it takes for you to slowdown. You can also use a clamp on “speedFactor” (I use from 0.2 to 1.0) to make sure that simply tapping the forward key will result in smooth motion, rather than weird jumpy motion. Blueprints and timeline attached for extra details. You can use “Set Play Rate” to change the speed at which the timeline is executed, or you can simply start from a later time (using Set New Time)

Many thanks for posting this solution. I haven’t come across timelines before and am reading through them with your solution. Am not sure on “from (t=0, cooldownFactor=1) to (t=1, cooldownFactor=0)”; does the t represent and how is it set? Would you be able to attach the timeline graph?

Just as an aside, it makes it a bit tricky to see what is being divided and multiplied with the boxes side-by-side and hiding the connectors.

I have been through all that I can find and I am unable to find out how to make the time on the timeline variable to allow it to take longer to slow down; is much better now with the deceleration but the time is fixed by the timeline. Could you let me know what I am missing?

Fixed! You can adjust the playback speed by using the “Set Play Rate” node.
See here for details: How do change the time it takes to complete a Blueprint Timeline? - Blueprint - Unreal Engine Forums

My suggestion (and if you implement it, I’d like to see the result) would be to create a single curve, always play it back at 1x speed and simply start the timeline from a different point (using the “Set New Time” node) depending on the character speed. For example, something like:

newTime = 1.0 - clamp (characterSpeed / characterMaxWalkSpeed, 0.2, 1)

would set the starting time to 0.0 s when the character is full speed, and 0.8 s when the character is at a minimum speed. This assumes your timeline is only 1.0 s long.

To clarify, my timeline is just a two-point timeline from (0,1) → (1,0) with cubic auto set for both. it should be linear though

Apologies for the delay; will get back to you shortly.

Apologies again for the delay in replying; have just had very little time in the last few weeks. I have taken a sub-set of the above and simply created a time for the deceleration timeline to reach zero; with a velocity of 0 to 6000, I just obtain a number of seconds by dividing the velocity by 2000.

When the forward movement axis is 0, the deceleration timeline is kicked off (as long as it is not already running). If the forward movement axis is 1, then the deceleration is stopped. If the velocity is below 150, then the deceleration is not kicked off to ensure no kangaroo hopping.

I have attached the blueprint for any feedback on the approach.