Description
What problem does this solve or what need does it fill?
It's very common in games to want to assemble animated characters out of separate parts. This includes things like clothing and armor styles, weapons, hair and jewelry, and so on. Often the parts will be multiple skins which all share the same armature, however in the case of weapons these might be separate meshes which don't have an armature of their own but which are simply attached to a "weapon bone".
A complete solution involves not only the game engine but the authoring process as well: characters need to be exported in a way that allows individual skins to be assembled dynamically at runtime.
While it is possible to accomplish this in Bevy, the process is not easy. Note: I have looked at the "modular characters" video, but honestly most users do not want to sit through a three-hour video tutorial, especially given that the resulting code is both complex and depends on internal details of skeleton structure that might break in future Bevy versions.
What solution would you like?
A complete solution would have the following requirements:
- First, there would be documentation about the process for creating compatible .glb files.
- If there's any preprocessing needed for the .glb files (such as splitting attachments into separate scenes) tools should be provided for this. (I have written tools like this in JavaScript using gltf-transform).
- There would be an API that allows spawning a character, starting with an armature asset path. The API would provide a way to add skins and attachments to the armature. These would be specified as asset paths.
- It should work regardless of whether the skins and the armature are in the same GLTF file or in different files (GLTF allows this).
- The solution should avoid spawning multiple copies of the armature for a single character.
- If the various attachments are stored together in a single GLTF file, the solution should avoid loading the file multiple times. In fact, it's probably best if there's a way to hold on to the root asset in the asset cache so that multiple characters can be spawned without having to re-parse the GLTF file.
- I bring this up because currently when you load a labeled asset, the labeled asset is cached but it does not retain a strong handle to the root asset. This means that if you later load a different labeled asset from the same file, it will re-load and re-parse the asset from scratch.
- The solution should allow post-processing of the character materials, such as color remapping, morphing and so on. While these kinds of things are out of scope, it should be possible to write an observer that traverses the entity hierarchy and makes the appropriate substitutions.
- Once the character and their attachments are ready, we can animate the character by assigning animations to the armature in the standard way.
What alternative(s) have you considered?
Well, the two alternatives I can think of are (a) rolling my own implementation and (b) relying on a third-party extension to Bevy. I don't actually know of a library which does this, although it's possibly I am simply lacking the correct search term. But given how many games need this kind of functionality, it seems like something that should be built in.
In particular, one advantage of it being built in is performance: this is the kind of thing that's easy to get wrong, and a built-in solution is much more likely to be optimal.
Additional context
This set of requirements is similar to what I had in my JavaScript/three.js based engine that I used before switching to Bevy.