Problems With Timeline Movement Speed

I am trying to create a crouch-slide function for a project I’m doing for a game jam, but I am having trouble getting it to work right. The Timeline has float track with a starting value of 2000 and an ending value of 300 (Yes I know that is insanely fast) and has a duration of 1.5 seconds. I’m relatively new to blueprints and any help at all would help me out greatly!

Problems:

  • Once the timeline completes once, it doesn’t work afterwards at all, it just stays on the value that is marked on the end of the timeline.
  • I can’t seem to figure out how to have the crouch slide not activate if the character is not moving.
  • I would like to have the character mot be able to move around as easily when sliding. Right now movement is not impacted so it can feel unnatural.
  • I would also like the first value of the timeline to correspond to the players current speed. I’m not sure how to hook up a “Get Max Walk Speed” to the timeline.

Thanks! -J5

  1. Timelines do not reset after they are finished. You could set new time to 0 if it is at the end of the timeline
  2. Just use a branch to check player velocity (Might be a variable in the movement component) is > 0
  3. You could divide player movement input by like 5 if the player is in a slide
  4. In that case, you are probably better off having the timeline going from a value of 0 to 1, and then using that value as the Alpha input on a Lerp, then lerp from the player’s slide start speed to whatever max speed you want. You’d set a variable to the player’s speed when they start a slide.

I’ll just add that you should use *PlayFromStart *execution pin rather than Play if you need the Timeline to restart from the beginning.

Thanks for the response! PlayFromStart did allow me to activate the timeline more that once, but I am having an issue where if you release ctrl before the timeline finishes, you remain crouched permanently until you hold ctrl for the entire duration of the timeline.

You need to stop the timeline when releasing crouch. You can do this using a Sequence node to Stop it, and then uncrouch. Your Uncrouch function will also not work. Your cast node is not being ran, so the return value is invalid.

Thanks for the response! I am however having some trouble getting it to work properly. What is the name of the node described as “player movement input”? I am having trouble finding it. Also after I have the timeline plugged into the alpha input on a Lerp, I’m not sure exactly how to do the rest of it. Could you maybe send me a screenshot or give a detailed description of how exactly I would set that up?

Awesome! That Fixed it!

A lerp is a linear interpolation, it blends between two values, using an alpha. The alpha is a value from 0 to 1, that is how much to blend. If A is 12, and B is 15, an Alpha of 0.5 would output a value halfway between 12 and 15 (13.5). In your case, you would blend from the character’s movement at the time of the slide, and whatever speed you want. You’ll want to get the player speed/velocity from the Character Movement node that you already use to crouch.

I set the timeline to start at a value of 0 and go to a value of 1 over the span of 1 second, but now when I crouch there is no movement speed at all, resulting in the player just staying in place.

Never mind! Turns out there was a typo in the timeline. Everything seems to be working well now. Thanks!

Actually I’ve already run into another issue, sorry! Something is wrong with the Lerp blending, as it only properly works while walking or just plain crouching. While sprinting, however, when I press ctrl, the speed seems to revert to walking speed and then initiate the slide. After that default walk speed is much slower, similar, if not identical to the crouch speed.

EDIT:Figured this out as well, there was conflicting max walk speeds in the character movement and in the sprint blueprint.

You’ll want to lerp from the speed at the start of the slide, not the current speed, or max speed. You can do this by storing the player’s velocity vector length inside of a variable when the button is initially pressed. If your speed at the start of the slide was 300, the player’s speed would remain at 300 for the duration of the slide, since you are lerping to 300. Right click that cast node, and turn it into a pure cast, otherwise the crouch function won’t run.

Any Idea how to make the time of the timeline proportional to movement speed? (i.e. sprinting then sliding will slide you further than walking)

There is no built-in way to change the actual length of the timeline, but there are some tricks you could use. Once you figure out how long the timeline should actually run for, you could set the new time to account for that, so like setting time to 0.2 in order to have it run for 0.8 seconds, and then lerp your previous Alpha value from the alpha that the timeline will start at, to 1. It might be easier to use the ‘map range’ node for this instead. You would remap a range of 0.2 (Whatever alpha the timeline will start off with) to 1, to the range of 0 to 1.

I was having difficulties with the other methods, and I know this isn’t the best or most efficient, but this is what I came up with.