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.