Add Motion Warping
Last modified: 05 December 2024Motion Warping can adjust root motion animations to shorten or stretch their movement, so they will properly reach targets.
Add the
NinjaCombatMotionWarpingComponent
to your base Character C++ class or Blueprint.Implement the `GetMotionWarpingComponent` function, returning the Motion Warping Component just added.
note
You might have already done this before, while configuring Opportunity Attacks. If you did, then you can ignore this step!
Create a new Targeting Preset. It will be used for the warp target selection.
Add the Current Target Selection Task. This will prioritize any target that is currently selected.
Add the AOE Selection Task. Use a Sphere shape, add Pawn and World Dynamic as Collision Object Types, set it to ignore the source actor and instigator, and a radius of 1600.
Add the Actor Class Filter Task. Set your base Character Class as the Required Actor Class Filter, or adjust these filters to match your character hierarchy.
Add the Facing Filter Task. Set the maximum angle to 60, or any other value that makes sense to you.
Add the Dead Filter Task.
Add the Sort By Distance Filter Task.
Open your Gameplay Ability for the first Melee Attack in the main combo.
Enable Motion Warping by checking the appropriate property.
Leave the default Warp Target Provider unchanged. The first attack will only warp if a target is locked.
Adjust the Warp Offset as necessary, providing a distance to be kept between attacker and victim.
Repeat these steps for all _first_ or _single_ attack abilities that you need to use warping.
Open the follow-up Gameplay Abilities that will continue the combo with melee attacks.
Same as before, enable Motion Warping and adjust the Warp Offset.
Change the Warp Target Provider to Targeting System. Set the Targeting Preset created in the previous step.
Repeat these steps for all _follow-up_ attack abilities that you need to use warping.
Open the Animation Montage for the first Melee Attack in the main combo.
Add the Motion Warping Anim Notify State at the beginning of the animation, for a reasonable stretch.
Set the Warp Name in the Notify State to
CombatWarp
.Repeat these steps for other Animation Montages used for other Melee Attacks.
note
Make sure to check the Motion Warping page for more information on how to configure your warping.