For the dashes and knockbacks in my Quod Combat Framework I use the root motion source tasks from the Gameplay Ability System ( GAS ), and there are no calls to LaunchCharacter anywhere in the framework.
I think these tasks deserve more use, so today I want to go through how they work.
When you create a dash you need the capsule to travel a certain distance in a certain time. If that movement is baked into the animation, every time you want to retune the distance you have to go back to the animator.
And for a knockback we don’t even know the direction and the strength until the hit lands.
With the UAbilityTask_ApplyRootMotion family we can give the Character Movement Component ( CMC ) a motion that is computed when the ability activates, so we are able to set the movement from code.
ApplyRootMotion tasks that come with GAS
There are five of them, and you can find them in the Abilities/Tasks folder of the GameplayAbilities plugin:
| Task | Motion it produces |
|---|---|
UAbilityTask_ApplyRootMotionConstantForce | a straight push along a direction for a duration. The dash and knockback workhorse |
UAbilityTask_ApplyRootMotionJumpForce | a parameterized arc with a landing callback, for leaps and jump attacks |
UAbilityTask_ApplyRootMotionMoveToForce | move to a fixed world location over a fixed duration |
UAbilityTask_ApplyRootMotionMoveToActorForce | like move to, but it keeps re-aiming at a moving target, for grabs and lock-on lunges |
UAbilityTask_ApplyRootMotionRadialForce | push away from ( or pull toward ) a point, with optional falloff |
As you can see they are useful for more than dashes. Ex: a ladder climb with MoveToForce, flying mode and one move-to per rung chained with the finish delegate, with no physics and no root motion clips.
What the task actually does
Even though the name says “root motion”, these tasks don’t read any animation.
What happens in the Activate of the task is that it builds an FRootMotionSource struct ( declared in GameFramework/RootMotionSource.h ), gives it to the CMC through ApplyRootMotionSource and stores the ID that the CMC returns.
While the source is in the CMC, the CMC will add it to its own velocity on every move, and the task only tracks the duration and fires its finish delegate at the end.
So the task is giving the velocity and the duration, and it’s the CMC that moves the capsule.
You also have the bIsAdditive parameter, which decides how the source mixes with the normal movement.
If you set it to false the source overrides movement for its duration, so input, friction and braking stop mattering, and that’s what you want for a dash.
If you set it to true the force is added on top of the normal movement, which fits better for a shove while you keep running.
Creating a dash ability
Let’s see how this looks in a minimal dash ability:
void UGA_Dash::ActivateAbility(const FGameplayAbilitySpecHandle Handle,
const FGameplayAbilityActorInfo* ActorInfo,
const FGameplayAbilityActivationInfo ActivationInfo,
const FGameplayEventData* TriggerEventData)
{
if (!CommitAbility(Handle, ActorInfo, ActivationInfo))
{
EndAbility(Handle, ActorInfo, ActivationInfo, true, true);
return;
}
const FVector DashDirection =
GetAvatarActorFromActorInfo()->GetActorForwardVector();
UAbilityTask_ApplyRootMotionConstantForce* DashTask =
UAbilityTask_ApplyRootMotionConstantForce::ApplyRootMotionConstantForce(
this, TEXT("Dash"),
DashDirection,
DashDistance / DashDuration, // Strength is a speed in cm/s
DashDuration,
/*bIsAdditive=*/ false,
/*StrengthOverTime=*/ nullptr,
ERootMotionFinishVelocityMode::ClampVelocity,
/*SetVelocityOnFinish=*/ FVector::ZeroVector,
/*ClampVelocityOnFinish=*/600.f,
/*bEnableGravity=*/ false);
DashTask->OnFinish.AddDynamic(this, &UGA_Dash::OnDashFinished);
DashTask->ReadyForActivation();
}
void UGA_Dash::OnDashFinished()
{
EndAbility(CurrentSpecHandle, CurrentActorInfo, CurrentActivationInfo,
true, false);
}Strength is a speed in cm per second, so the distance is simply the strength multiplied by the duration.
This means that if you pass DashDistance / DashDuration you get a dash that travels the distance you asked for, and both values are plain properties on the ability that a designer can tune without touching any animation.
On top of this you play a cosmetic dash montage with PlayMontageAndWait, using a clip with no root motion at all. As the source is moving the capsule the animation only has to look right, so you can use the same numbers with any character.
Try to keep only one movement driver per ability. If you combine animation root motion with an active root motion source you have two systems controlling the capsule, and the result is arbitrary.
For an attack that needs to adjust its animation to the target, I use motion warping.
Using the same task for knockbacks
For my knockbacks I use the same constant force task, but the property that I expose to designers is the distance in meters, which is something I recommend doing for hit reactions.
The task receives that distance plus a normalized strength-over-time curve that shapes how the push slows down.
When it activates it integrates the curve once to get its average value, and with that it solves the strength so the push covers the distance we asked for, Strength = ( Distance / Duration ) / AverageCurveValue.
This way “this attack pushes 2.5 meters” is true whatever the shape of the curve is, and combat designers can tune the knockback in the same units they use to think about spacing.
While the push is active the hurt reaction montage has its root motion disabled, so the montage gives us the pose and the force moves the character.
We also wait around 0.09 seconds before starting the force, so the impact frames of the reaction get some time on screen before the body moves. I like how the hits feel with that small delay.
Why does the character slide after the dash?
Sometimes you will see that the character covers the distance you asked for and then slides a few more meters while braking friction stops it. If this happens to you, check ERootMotionFinishVelocityMode.
With MaintainLastRootMotionVelocity the final velocity of the source passes to the normal movement, so a 1500 cm/s dash leaves the character moving at 1500 cm/s after the task ends.
SetVelocity lets you choose the exit velocity, and ClampVelocity caps it at the value you pass.
My recommendation is to use SetVelocity with a zero vector for knockbacks and ClampVelocity at your run speed for dashes, so the dash blends back into locomotion.
Cancelling the ability
Remember that the source lives in the CMC, and the only thing that removes it is the OnDestroy of the task calling RemoveRootMotionSourceByID.
The task is destroyed when it finishes or when the owning ability ends, so every cancel path of your ability has to reach EndAbility or CancelAbility.
If one of them doesn’t, you can get a character that is stunned mid dash and keeps travelling anyway, with no animation explaining why. What happened is that the stun cancelled the montage, but the source is still inside the CMC pushing the capsule for its full duration.
And if you apply an FRootMotionSource to the CMC by hand, without a task owning it, removing it is on you.
How does this work in multiplayer?
Root motion sources don’t use GAS prediction at all. They are a character movement feature, so they replicate and predict the same way that CMC movement does.
The owning client applies the source locally and starts moving immediately, and the source gets recorded in its saved moves.
Then the server runs the same ability and applies the same source, and if the two of them diverge the correction comes back through the normal CMC adjustment.
Simulated proxies get the motion too, as the tasks replicate their parameters through the gameplay task machinery ( the shared code is in AbilityTask_ApplyRootMotion_Base.h ).
Also take into account that if the server rejects a locally predicted activation, the prediction key rollback will undo the tags and effects that GAS predicted, but it will not un-move the capsule. What snaps the character back is the CMC correction, and on screen that looks like a rubber band.
So for movement abilities keep CanActivateAbility cheap and checking only things that client and server agree on.
And don’t try to gate the source on prediction key callbacks, the task and the CMC already handle both sides.
Movement mode, ledges and walls
While a source is active the CMC keeps running its movement mode, and this changes the result in some cases:
- In walking mode the floor logic stays active, so a dash that leaves a ledge transitions to falling mid dash, and ground snapping fights any upward component of your force.
- bEnableGravity decides if gravity accumulates during the push. With it disabled a flat dash holds its line over a small drop.
- The move-to tasks expose bSetNewMovementMode, usually flying, so walking physics leaves the move alone, and they restore the previous mode when the task ends.
- None of these tasks navigate or resolve collision. A constant force pushes into a wall for its full duration and the capsule slides along it, so validate your destinations and accept that a blocked dash ends at the wall.
If you want to look at the correction code, it’s in FRootMotionSourceGroup, in GameFramework/RootMotionSource.h. It has changed between engine versions, so check the headers of your version if you subclass FRootMotionSource or depend on precise correction timing.
Recap
So, in the end, these are the things I would remember when using these tasks:
- Every cancel path of the ability has to end the ability, as the source lives in the CMC and only the OnDestroy of the task removes it.
- Use SetVelocity with zero for knockbacks and ClampVelocity at run speed for dashes, as MaintainLastRootMotionVelocity turns the dash speed into a skid.
- Keep the activation checks of movement abilities cheap and the same on client and server, as a denied activation snaps back with a CMC correction ( the rubber band ).


