Climb Dash

Lastly we want to be able to "dash" while climbing to give our players a choice to speed up traversal (usually at the cost of increased stamina consumption, not that we have stamina atm)

Defining Dash Velocity

A key part of the dash visually is the feeling of anticipation for the dash just before the dash

The character doesn't immediately dash when you press the button, they wait for a split second as if the character is channeling their energy to lurch in a direction

Additionally their Velocity changes similar to an easing function like so (left to right) such that the Velocity increases rapidly at the start, then slows down gradually at the end

So what we'll need is another Animation Blendspace (the account for dashing in all 8 directions) and a Velocity function representing the above example.

For the Velocity function we'll an Float Curve which maps a speed (in cm/s) to seconds

Here I want my animation to only play for 0.6s, have a pause of no Velocity for the first 0.2s, then a rapid increase for the next 0.1s, then slow down for the rest of the 0.3s.

Now lets create a reference to store our curve as well as some necessary metrics we need to perform our dash like dash direction, a bool indicating we're in the dash state, and a float to keep track of our dash time.

Dash Physics

.h

Additionally lets create a function to handle dashing.

When the character presses the dash button we'll set bWantsToClimbDash to true, and use the characters acceleration as our bases for ClimbDashDirection (no input defaults to character's up) and reset the CurrentClimbDashTime (which we use to map from a time to speed in ClimbDashCurve)

.h

.cpp

We still need to hook dashing into our physics so lets do that now.

Before calcualting the velocity, we want to update CurrentClimbDashTime so that if we are dashing we only dash as long as the curve is.

.h

Add the call to UpdateClimbDashState after we compute the surface info but before we compute the velocity

.cpp

Now we need to use our climb dash speed taken from the float curve if we're in the bWantsToClimbDash state when computing velocity.

We do this by extracting the value of the curve at the given time.

However we want to support dashing around corners so we'll need to align our CurrentClimbDirection with the surface.

.h

.cpp

Aligning Dash Direction with Surface

The idea here is that we only want to dash along the surface (horizontally and vertically).

So that means we can ignore the Z component of the surface

Then we can align the dash direction (which was previously defined by the character's acceleration) by projecting it onto the plane which is defined by the surface normal

(yellow) acceleration, using each surface's normal to define the XY plane

.cpp

Updating Physics Speeds

One more thing we should do is take the Velocity into account when defining our GetClimbingRotation() and ClimbingSnapSpeed since our Velocity could be rapidly changing if we're dashing.

.cpp

Dash Animations

Lastly we need some animations.

Create a new Blendspace similar to our climbing Blendspace, except for dashing we can use a 1D Blendspace since speed isn't something it needs to account for.

8 Grid Divisions again, but this time the axis values should just be +/- 1

Then in the Anim Graph create two new variables, a bool to store IsClimbDashing and a 2D Vector to store the ClimbDashVelocity

And set them in the Event Graph (using our handy Velocity to 2DBlendspace function)

Create a new State in the Locomotion State graph with the appropriate transition rules for climb dashing

And finally add in the blendspace

Now we can climb dash in any direction, and it handles corners and edges!

Last updated