0

So I have this GLTF model that I import into a three.js scene. The model itself is created in blender where I created a character that I have rigged and I created a few different animations with separate names (IdleAction, StartAimingAction etc). I then save this as a glb-file which includes the animations I created. I can successfully load this glb into my three.js scene and display any of the animations I created.

I now tried to duplicate the character (both mesh and armature) so that I have 2 characters. I did this by selectin both mesh and the armature in Blender and shift+D to duplicate. I then save to glb and load into my threejs scene. It seems when I do this I get two instances of every animation (check the image below). For instance I have 2 animations both with the name "IdleAction", one for each character. But there seems to be no real way of knowing which animations belongs to which object. For instance I have 2 animations both with the the name "StartAimingAction" (one for each character), but how can I choose programmatically to for example play one animation for character 1 and another animation for character 2 if I can't see which animation belongs to which character?

This so far is just a test, because my aim is to have a scene with 100 of these soldier characters, which will be incredibly messy if that means 100 animations of every type. Since I have around 5 different animations that I created that would result in 500 animations.

enter image description here enter image description here

It would be so much nicer if the animations became of a part of the actual character object instead (see arrow in image below), but those lists are always empty, instead all animations are a part of the "animations" list in the gltf root object. (BlueSoldierTemplate and BlueSoldierTemplate001 are character 1 and 2 in the image).

enter image description here

1 Answer 1

1

You will probably want to duplicate your soldiers using code instead of modifying your blender file.

The AnimationMixer has a rootObject property that you can specify on its constructor. Each soldier would need to have its own AnimationMixer, with the rootObject pointing to the object clone that it will animate.

With this approach you don't need duplicate animation definitions for every soldier, you also don't need to export more than a single soldier from blender, as it would increase your asset filesize.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the answer. Yes since I posted this question I realized that this was not a very good approach. My new idea is to have on gltf-file for the actual map/world, and a single gltf for the soldier. I then import the soldier-model only once and then duplicate it programmatically and place it in the world wherever I want. I can then animate each soldier individually. I haven't gotten around actually implementing this yet though

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.