Godot 4: Apply 3D AnimationTree Root Motion Values to Parent's Position Based on Child's Local Y Rotation?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By CFR_Godot

Hi everyone!

I’m working on a 3D third-person shooter game and while I’m starting to learn the ins and outs of AnimTree, I can’t wrap my head around actually applying the rootmotion transform gathered in my particular instance.

My setup, fully credited to Pemguin005’s Soulslike Third Person controller, is to have a “Player” node which has an “ActorMesh” node attached to it - the player is the actual physical movement and logic and does not rotate while the ActorMesh conveys the current direction, actions etc. by rotating towards the direction angle on their Y axis and animating appropriately.

The AnimTree in my case is a child of the ActorMesh along with their AnimPlayer, but both are easily accessible from Player using a “ActorMesh_AnimTree”/“ActorMesh_AnimPlayer” variable.

I was wondering if it’s possible to gather the root motion transforms from ActorMesh’s AnimTree and apply it to Player’s position based on ActorMesh’s local rotation - the idea being that if ActorMesh does an attack animation with Root bone motion, Player would be moved in whatever direction is forward, backwards, right or left for ActorMesh.

Thanks to Pemguin005’s Soulslike Third Person controller and a few “move in direction” suggestions found online, I’ve ended up withvelocity = (child_node).global_transform.basis.z.normalized() * amount to give me a great little function to trigger a quick push forward to emulate rootmotion, but it’d be amazing to have the full breadth of Rootmotion available to use on attacks.

Thank you very much for any suggestions!

P.S. I don’t have the programming know-how to make a proper suggestion but to the Godot devs, a section under the AnimationTree’s Rootmotion tab to toggle automatically applying the gathered Rootmotion transform value to another Node’s local or global transforms would make that whole system infinitely more usable IMHO!