Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Root motion works unexpectedly with some models #75228

Open
frnsys opened this issue Mar 22, 2023 · 9 comments
Open

Root motion works unexpectedly with some models #75228

frnsys opened this issue Mar 22, 2023 · 9 comments

Comments

@frnsys
Copy link

frnsys commented Mar 22, 2023

Godot version

4.0.1rc

System information

Ubuntu 22.04, Intel Skylake GT2 [HD Graphics 520], Vulkan

Issue description

I'm not sure if this is an engine issue or not, but with one of my character models root motion isn't working as expected.

This is the original animation:

I set up the root motion and the character stays in place as expected, but the interpreted movement shows no forward movement:

I also notice that if I uncheck "Zero Y" in the RootMotionView the floor drops away:

I can't figure out what the cause might be as the original animation looks correct.

Steps to reproduce

In the attached project the person.tscn demonstrates the case where root motion isn't working as expected. The other two (mixamo.tscn and mixamo_rotated.tscn) are examples where it's working fine.

Minimal reproduction project

root_motion_issue.zip

@TokageItLab
Copy link
Member

TokageItLab commented Mar 24, 2023

The problem is that your root bone has a strange Rest axis. You need to use retargeting or something so that +Z is forward like the other gltf assets.

@QuiGonMaul
Copy link

I encountered this today when testing in Godot 4.0.2.

If you've rigged and animated character in blender, then you're working in a space with the Z axis as the up and down axis.
As most users may know, it is instead the Y axis that is the up and down axis in Godot.
This hasn't been an issue up until now, because when you export from blender you can check the option "+Y Up" which orients the character correctly when importing into Godot.

However, it appears that the 'root motion view' does not interpret the converted orientation of the imported character, which is why you get the purple root motion grid moving down the Y axis - its using the character's orientation as if it was still in blender and thinks that the Z axis is still up and down.
I hope all that made sense.

This is definitely a bug with Godot 4.0 because this works perfectly in Godot 3.5
I even tested it by exporting a character without the "+Y UP" setting checked, but that results in the imported character not being oriented correctly in Godot.

@TokageItLab
Copy link
Member

TokageItLab commented May 1, 2023

@QuiGonMaul See also #75843 (comment).

Blender uses +Z up for object space, but the cameras and bones uses +Y up (for the Edit bone, it may be confusing since the Local transform always looks like +Z up, but if you set the gizmo option to Normal, you can visualize the bone axis), so this should not be a problem as long as the model has Root bones in Blender and bone animations are used. I think the problem is probably caused when the Root motion is created as an object animation or AutoRig in Blender.

One currently available fix is to apply retargeting to Root bone with Overwrite Axis and Apply Node Transform.

@QuiGonMaul
Copy link

As far as I understand, everything else works perfectly as it also does in Godot 3.5, except the 'root motion view' purple grid.
To clarify, I'm using a blender created animated character rig that faces forward in blender's -Y axis and then exported with the +Y Up option enabled.

Without changing any settings on this imported character from blender (including suggested re-targeting fixes etc.), I'm still able to get a properly working animated character that uses root motion driven animation when running a build.
So this confirms in my experience that its only an error with the 'root motion view' itself not previewing the purple grid motion correctly, which is somewhat of a relief because its not essential to the game build and its only there as a visualisation tool - as far as I know.

@TokageItLab
Copy link
Member

TokageItLab commented May 1, 2023

Is the your Rest of Root Bone the initial Transform? (Is the Root Bone pointing up correctly in Blender?)

In Godot 3.x, the motion result gets a relative value from the Rest, whereas in Godot 4.0, it gets an absolute value from the initial Transform: Animation data rework for 4.0. Therefore, Godot 4.0 should not include rotation in the Rest of the Root Bone.

@QuiGonMaul
Copy link

Yes, my root bone for the rig in blender is oriented correctly with the rest of the bones (+Z axis up, and facing forward in the -Y axis).
I have successfully managed to get the character to rotate using root motion in Godot.

I should also mention that when testing the character's root motion rotation in Godot using 'root motion view', it causes the purple grid to rotate along Godot's Z axis, giving the effect of the entire floor plane spinning on its side.
To me, this suggests that Godot recognises the change in the character's orientation in a running build (essentially swapping Z for Y axis during the export/import process), but fails to recognise this change in the 'root motion view'.

@TokageItLab
Copy link
Member

TokageItLab commented May 2, 2023

As I said above, blender uses +Y up (+Y roll) for bones and the all bone axes are never changed by the +Y up option, so the root bone must be +Y up (Edit bone's Tail must be placed upward of the Head, and the roll is 0; which is the same as the bone that is added when the armature is added to scene) in blender, not +Z up as long as it is bone.

Also you can check the bone axis (rest) with this add-on in blender.
https://github.com/TokageItLab/blender-addons/tree/main/bone_rest_info

@elXill
Copy link

elXill commented Sep 30, 2023

I'm having this problem as well.
First my model export rig in blender: Z is forward
Armature
Second my animation root motion in godot: As you can see it animation is in Z axis also movement in 3d scene also going forward which is also correct.
Godot Root
Other than this when I use code below, it also works like expected.
char_transform.global_transform.origin = char_transform.global_transform.origin +my_anim_tree.get_root_motion_position()
But after all these,In RootMotionView node Z and Y axes are mixed up same as the OP showed.

After checking @TokageItLab 's comment I have changed the orientation of root bone like below and the problem is solved but I think these shouldn't be related and this is a hacky solution, so I still hope this would be fixed in the future.
Godot Root2

@TokageItLab
Copy link
Member

TokageItLab commented Sep 30, 2023

Blender uses +Z-up for objects/world, but +Y-up for cameras, lights, and bones.

The axis of the root bone is preferably "aligned with the world axis of the final environment to be used". Bone axes are not converted by glTF-IO, so if they are aligned to blender's world axis, they will not be aligned to godot's world axis. So this (using +Y-up on the root bone and other bones) is not a hack, but if I had to say that rather the role of the blender-glTF exporter to fix a strange condition where only the root bone uses a different coordinate system than the other bones (although I've never seen an official article recommending that blender point the root bone tail back and using +Z-up for the bone in the first place).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants