KhronosGroup / KhronosGroup/UnityGLTF

Better implementation of humanoid avatar creation (use hierarchy instead of names)

Open
#911 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
2.2k
Forks
536
PR merge metrics
No merged PRs in 30d

Description

### Describe the bug 💬

(not a bug but choosing a different issue template does not work)

Humanoid avatar creation has been a pain point for a few people it seems (me included), especially considering there is no way to configure it.

As others have mentioned the way the FBX importer handles this is opaque and undisclosed, but one thing I am certain of is that it does not care about the names of the bones (apart maybe to differentiate left and right bones). It only expects a specific hierarchy.

We should find the hips bone, which is the first bone with three children including two that have respectively a .L and .R suffix.
Then we walk the .L and .R bones which are the legs, first bone is upper leg, seconds lower, third is the foot etc.
The last child of the hips is the spine, walk along it until we find the same pattern as the hips, .L is left arm and .R the right.
If the arms only contain three bones then we skip the shoulder, because it's optional.

You get the idea.

Here's a rig I made without renaming the bones apart from .L and .R suffixes, everything gets assigned automatically correctly:
Image

I have attached both a .glb and .fbx file of the rig.

### Steps to reproduce 🔢

[Rigs.zip](https://github.com/user-attachments/files/31653963/Rigs.zip)

### Files to reproduce the issue ♻

_No response_

### Editor Version 🎲

6000.0

### Render Pipeline and version

URP

### UnityGLTF Version

2.20.0

### Operating System 👩‍💻

Linux

### When does this problem happen?

- [ ] Editor Import
- [x] Runtime Import
- [ ] Editor Export
- [ ] Runtime Export

### Additional Info 📜

@XtroTheArctic this is probably of interest to you.

I might make a PR myself and implement this since it's not that big of a change. Maybe we should keep the name dictionary just so other people's rigs that worked don't get broken (although if they do get broken they probably didn't respect the hierarchy that mecanim expects anyway).

### 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 with the runtime humanoid avatar creation path in UnityGLTF and reproduce the behavior using the attached Rigs.zip files. Compare the current name-based handling with the hierarchy and .L/.R suffix rules described in the issue; done means the supplied rig imports correctly without renamed bones while existing supported rigs remain usable.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, unity
Domain
game-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.