Add Motion Warping
Motion Warping can adjust root motion animations to shorten or stretch their movement, so they will properly reach targets.
Add the Motion Warping Component
Add the
NinjaCombatMotionWarpingComponent
to your base Character C++ class or Blueprint.Implement the `GetMotionWarpingComponent` function, returning the Motion Warping Component just added.
Configure Melee Target Presets
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.
Update Initial Attack Abilities
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.
Update Follow-up Attack Abilities
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.
Add Motion Warping Notify States
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.
Test Everything
Hit Play and try to attack the enemy from far, no warp should happen.
Move closer, within warping range and attack the enemy. Warping should happen.