Question about root motion animations

So I have the Amplify animations pack I picked up on sale a while back. I thought I’d have a look at those for some sword swinging animations. I found one I liked but quickly realised the animation data is a mess without root motion turned on. So I quickly modified the project to enable and disable root motion for the existing animations to work as they already do. I also added one of their strafing animations on the return transition to idle which walks the character back neatly. The character wildly swings forward a couple of steps then strafes backwards. It looks great but…

The main issue appears to be timing and orientation. In short I need to figure out how to get the character back to the starting point each time, otherwise the errors compound until the character mesh is way off the Unit transform. I suppose one approach would be to lock root motion down for the return animation and have the strafing animation play while the character is forcibly moved back to the correct spot? In that case I suppose I’d have to add some more state and movement logic to UnitAnimator.

Is there a generalised good approach to this sort of thing or is it more tweaking until it looks right. The animations do look good but I’m not really sure how best to get everything to sync nicely.

Thanks for any help.

Ok, so after a bit of work I got something half decent. Video Here. Still needs a lot of polish to smooth the transitions and I’m not sure why the animation is dipping into the floor like that…

So what I ended up doing was adding another state to SwordAction, and moving the weapon swapping logic into SwordAction. I created a third event on…Hit and spent a while trying to figure out the timings of things.

OnStartSwordAction triggers the animation as normal via UnitAnimator which sets ApplyRootMotion true. After the elapsed time SwordAction.NextState() calls the new on…Hit event and the UnitAnimator disables root motion and sets IsWalking animation bool true, triggering the back strafing animation. The final SwordAction.State walks the Character transform back to (local! - that was a fun bug) zero within .2f and finally NextState forces the character transform to be exactly local zero; on…Complete fires and the UnitAnimator sets the IsWalking bool false and transitions back to idle. It’s not quite as slick with all the animations set to apply root motion but everything ends back up in the right place!

I did try looking into animation events but didn’t get very far with that.

I would handle this with Animation events, but there are many paths to the same destination. Adding additional animation states is an excellent way of handling this as well.

1 Like

Yeah using Root motion on a game like this one, where the character is meant to stay in their Grid Position, at least at the end of the turn, is indeed going to be tricky.

One option is to let the character move with root motion, but then after the action ends do some logic for the character to turn around and walk back to the origin of the grid position. Make sure you remember which object you’re moving, for walking back make sure you’re moving just the visual and not the parent game object.

Another option which is much simpler is just “remove” the root motion from the animation, meaning load it into Blender and edit it so it does not move.
Although at that point you might as well just look for an animation that was built without root motion.

1 Like

Privacy & Terms