In this lesson, you will learn how to manipulate the predicted movement path in your Motion Matching system to simulate natural weight, momentum, and physical limitations.
The Logic of Trajectory Modification
When using Motion Matching, the engine generates a "Trajectory"—a series of future points representing where your character intends to go. By default, this path is often mathematically perfect (instant acceleration), which can look robotic. Trajectory Modifiers act as a mathematical filter between your input (the controller) and the animation database search, allowing you to inject realistic physics behaviors like "sliding" into turns or gradual speed ramping.
Implementing Momentum Curves
Instead of feeding the raw controller direction directly into the Pose Search node, we can process the trajectory data within the Animation Blueprint's Update phase. By creating a custom logic flow, we can apply an acceleration curve to the trajectory points before they are used to select an animation.
Consider this simplified conceptual logic for smoothing acceleration:
// Pseudocode for Trajectory Modification
void ApplyMomentumModifier(FTrajectoryData& CurrentTrajectory) {
// CurrentVelocity is the previous frame's velocity
// TargetVelocity is derived from user input
// Apply a lerp based on a DeltaTime-driven acceleration curve
float AccelerationFactor = 0.15f;
CurrentTrajectory.Velocity = FMath::Lerp(CurrentVelocity, TargetVelocity, AccelerationFactor);
// Adjust future points to reflect this slower speed buildup
for (int i = 0; i < CurrentTrajectory.Points.Num(); i++) {
CurrentTrajectory.Points[i].Position *= CalculateMomentumMultiplier(i);
}
}
By scaling the future points of the trajectory, you force the Motion Matching system to search for animations that match a slowing down or speeding up pose rather than snapping to a full run.
Why Use Modifiers?
- Deceleration: You can artificially extend the trajectory length when the character releases the joystick, forcing the system to find a "stopping" or "skidding" animation.
- Acceleration: You can compress the trajectory at the start of movement to prioritize "start-up" animations, preventing the character from instantly hitting top speed.
- Responsiveness: You maintain a high-performance database search while layering on a layer of "physical weight" that feels custom-tuned to your character's specific movement style.
Key Takeaway: Trajectory Modifiers allow you to artificially smooth the transition between movement states by interpolating future path data, ensuring your character’s animations respect the laws of momentum rather than snapping instantly to user input.