How to achieve smooth transition between sprinting and slowing down?

Hello, it’s my first time… both on the forums and in Unreal Engine 5, I’m also not sure if I should create this topic in the Programming & Scripting section or somewhere else, but… anyway, let me get straight into the problem.

So, I basically have this function here:

and I’m using this Tick to “do things” to my function:

I’m also setting the booleans when the sprinting function is triggered or not:

What I want to achieve is pretty simple:

  • if the sprinting key was used
    AND
  • if the player is moving,
    = gradually increase the player character speed, set the speed to 10000.0 after the key was held for 10 seconds.
  • when the key is released, try to get current speed of the player character and within 2 seconds try to achieve the initial walking speed, so 600.0.

Unfortunately, right now, the player character starts sprinting rather slowly, I printed the actual moving speed and transition between the walking speed (600.0) to the desired sprint takes more than a minute and it can never even reach 10000.0. What’s worse, if the sprint key was held for a long time and then the player character hit any obstruction, the player speed will increase. The gradual slowing speed also doesn’t seem to work properly, because it clearly does not slow the player to 600.0 within 2 seconds, but way long.