If I have a couple different "class" of characters but I want them to use the same animation, even though they look different, how is that possible in Godot? I understand animations are applied to skeletons but how can I re-use the skeleton and animations with different meshes?
How do I share animations across different characters
- Edited
As of writing, Godot doesn't support animation retargeting yet, so you can't do that in the game engine, unfortunately. The proposal author made a C++ module for it, so you could try dropping it into the modules/
folder of a Godot Git clone and compile it: https://github.com/smix8/GodotAnimationRetargeting
There's also a pure GDScript add-on included, but it only has a limited feature set.
There is a gdscript method, but the skeletons would at least need the same named bones. You can get a node to the animationPlayer, then get the animation from it. After that you can get the AnimationPlayer for your target node, then add it. Look up AnimationPlayer in godot manual and you should see in the reference, it has get_animation("") and add_animation()
Thinking about it, would having a single "character" blender file, with a single skeleton and multiple meshes all attached to the skeleton work? Where I'm just hiding the meshes that aren't relevant when they're loaded into the scene?
That is a method I've been using. Problem is, the gemotry is getting deformed, even though it's not visible. It would slow things down. You could set the visible and invisible in script. Then free() on the ones you don't need. This is something I've tested, and it works. But if you need to say, equip a sword. You have to reload the whole model again.
I'm surprised to hear the engine is paying attention at all to meshes that aren't visible.
- Edited
To avoid skinning invisible meshes, you can use the VisibilityEnabler node to achieve this automatically, although it's approximate in 3.x
. In the master
branch, it has recently been reworked to be more accurate.
The engine skins invisible meshes because the result of skinning may be used for gameplay purposes (e.g. if collision shapes are present at the tip of a skinned mesh).
- Edited
Okay, I see.
So, maybe I should concentrate on other areas of my app for now.
Otherwise maybe the best solution is to use the experimental cpp code linked, or something making use of the add_animation
suggestion. Thanks for your help.