KhronosGroup / KhronosGroup/UnityGLTF
Root motion isn't applied to non-humanoid animations via Animator probably due to missing Avatar
- Dominant language
- C#
- Stars
- 2.2k
- Forks
- 536
- PR merge metrics
- No merged PRs in 30d
Description
### Describe the bug 💬
(See the EDITs below, first)
In this issue (https://github.com/KhronosGroup/UnityGLTF/issues/869) and in this PR (https://github.com/KhronosGroup/UnityGLTF/pull/870) I did set the Root Motion of the created Animator to true but it turns out, Animator requires an avatar to be able to apply root motion to non-humanoid models.
So, the avatar creation for non-humanoids must be added to UnityGLTF importer, making it consistent with FBX importer and compatible with Mecanim Animator.
As seen in this screenshot, the horse moves within its local space without moving the object itself (as shown at the location of Unity's Transform Tool Gizmo):

As seen here, Unity's FBX importer creates an avatar for non-humanoid model so that Animator can apply root motion.

***EDIT 1***
After working on fixing the non-humanoid avatar creation, I noticed that, to achieve proper root motion for a non-humanoid model, avatar creation alone is not enough. Even when the non-humanoid avatar is created and the animator's applyRootMotion is set to true, the model's gameobject isn't moved by the animator component during play mode. I think the imported animation assets needs to be setup correctly for them to be able to apply their motion to the model gameobject.
***EDIT 2***
This issue goes hand-in-hand with another issue I reported regarding Humanoid models: https://github.com/KhronosGroup/UnityGLTF/issues/874
### Steps to reproduce 🔢
Import the FBX and GLB from this zip and see that FBX model has an avatar and UnityGLTF model doesn't have an avatar.
https://github.com/user-attachments/files/20718763/Horse.zip
### Files to reproduce the issue ♻
https://github.com/user-attachments/files/20718763/Horse.zip
### Editor Version 🎲
Other (Provide details below)
### Render Pipeline and version
Not relevant
### UnityGLTF Version
2.17.1
### Operating System 👩💻
Windows
### When does this problem happen?
- [x] Editor Import
- [ ] Runtime Import
- [ ] Editor Export
- [ ] Runtime Export
### Additional Info 📜
_No response_
### Validations 🩹
- [x] I have [searched existing issues](https://github.com/KhronosGroup/UnityGLTF/issues): no issue already exist that reports the same problem.
- [x] I follow the [Code of Conduct](https://www.khronos.org/about/code-of-conduct)
- [x] I provided a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example), including files when necessary.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by importing the supplied Horse.zip in Unity and comparing the FBX and UnityGLTF results during play mode. Investigate the editor import path for non-humanoid avatars and animation asset setup, using the linked issues for context. Done means the imported non-humanoid model has the required avatar and Animator root motion moves the model object.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, unity
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100