Need some help with building a better dash player action.

Hey there. Recently, I’ve been working on some small snippets of code for leaning’s sake. However, when trying to build a standard dash mechanic for a first person character, that works as normal with jumping, crouching, and other default features of the Character class. I found out that a lot of the small details I want to cover are pretty hard to nail down with code using the Character class alone. Here is what I tried so far and how it failed…

Attempt 1: Launch Character

Most basic, and most crude. Just applying a single burst does not grant the right type of movement: Changing friction and braking for either ground or air movement do not let me control just how far the dash goes, or how long it takes to reach the destination. Even fine tuning this values doesn’t allow to ensure the dash shares the same behaviour mid air and on the ground.

Attempt 2: Line trace + Timeline

By far, the best result of the bunch. I can control the distance, the time, the acceleration, everything. The exact behaviour I want, logic wise, save for one singular issue that prevents it from being exactly as I need it:
Running into a ramp mid dash will cause the player to slow down dramatically, rather than simply slide upwards. Ideally, it should cover a similar distance as it slides upwards (I don’t have any exact math, but any ramp will just halt almost completely the dash for its duration)

Attempt 3: Flying Movement


The most convoluted of the bunch by far, and almost functional. It interacted properly with ramps, but doing the movement mode switch from flying to walking inherited a portion of the previous velocity, even if resetting it beforehand, which added extra distance to the dash based on the braking values, and made it impossible to properly set up a target length for the dash to work in both grounded and air dashes. Additionally, if the distance between the player and the ground was too short at the end of the dash (but not 0) the fall time would be instant instead of having a few frames where the player actor lands in on the ground.

All in all, my research got some results and hit some walls. I would like anyone’s suggestions to improve these methods, or any different way to do it altogether that covers the requirements I mentioned beforehand. Thanks in advance for your time and help.

Try it like so:

At least you will have eliminated yet another method that does not deliver.

Just tried it out. While it does make it dash, it doesn’t interact properly with ramps, so sadly it’s not fixing any issues for me.

You should post a video so Everynone can see what the issue is.

Here’s a recording of the Line Trace method as it felt like the best of the bunch overall in terms of accuracy.
Its only issue is the interaction with ramps, most of the movement is lost.

I had to make a really controlled dash and I ended up using UCharacterMovementComponent::ApplyRootMotionSource(). This method is not exposed to blueprints though and I haven’t tested it on ramps. It might have the same problems.

However, you can always get the ground normal from the movement component and rotate your direction vector to be parallel to the ramp making the speed constant regardless of slope.

1 Like

I only tried using the GAS Apply Root Motion Constant force. I’m not too sure how to make use of RootMotionSource however, since my c++ is very poor at best.

Is getting the ground normal from the movement component also something not exposed to blueprints?

Yea you can see from GAS how the root motion is applied although I didn’t need all the replication and async tasks.

The ground normal can be accessed in blueprints although it’s a bit convoluted:


(This should produce corrected forward vector)

1 Like