2
\$\begingroup\$

Using Godot 3.5.1, I need to make a system that switches armors/helmets/hair styles/weapons and so on.

I've seen a single tutorial for how this is done in 3D games in Godot, and apparently it is not the best system, it's just something some guy who didn't knew how to do it came up with. It is very hard to set up and very inefficient, as it makes the game way heavier than it should be.

I already have animations and a skeleton. What is the process now to make sure that all pieces can be swapped and work with the same skeleton in Godot? I've already tried swapping objects that follow no animations and they work just fine, but what about things that bend like fingers or legs?

Example of character mesh parts

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

The easier path is probably to export a single model with all the pieces, so you only need to toggle their visibility (or dynamically remove parts) in runtime.

The problem of that is that we might be talking of a single file, and would grow hard to maintain (version control), and will have an impact in your load times.


Alternatively, you would export multiple models...

For a model to follow a mesh in Godot:

  1. You need a Mesh that has bone weights (weight paint). You cannot set these from Godot, so you need a model exported with them, and take the Mesh from it.
  2. Set a MeshInstance with the Mesh. It is usually set as a child of the Skeleton so applying a transformation to the Skeleton also applies it to the MeshInstance.
  3. You needs to have a Skin set in the skin property of MeshInstance. The Skin has the references of the bone indexes, names, and rest position. You want these to match between interchangeable parts.
  4. You needs to have the Skeleton set in the skeleton property of the MeshInstance. By default the skeleton property will be set to the parent of the MeshInstance.
  5. The animations will move the Skeleton itself, not the MeshInstance, and MeshInstance will follow the movement of the Skeleton.

So, you would not change your Skeleton or AnimationPlayer, thus must stay the same. You would only swap the MeshInstances that are children of the Skeleton, and as long as they satisfy the requirements, they should work.

To get your interchangeable pieces into Godot you would export models with the same skeleton but with different parts. You would need to load the models and assemble the parts via script.


I also want to mention that if you want to have weapons or other pieces that do not deform but must follow the animation you can use BoneAttachments.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .