Independent animations on instances

I’d like to have instances with animations running at different speeds and starting frames. I suppose the problem would be the same as having different animations on instances. I bothered you people before about this :slight_smile: and it should be possible: Weekly Video: Fun with Instance Buffers

But I still couldn’t find a way to do it. Here’s what I tried: and the meshes are still in synchrony. What’s the mistake?

For this mesh, the animation comes from the skeleton and not the mesh itself.
YOu should check this: Use an AssetContainer - Babylon.js Documentation

1 Like


If anyone finds this post, here’s the announcement of AssetContainer.instantiateModelsToScene() and a PG explaining how to do it: Babylon.js Playground

1 Like

Minor question @Deltakosh, how do I add the instantiatedModel to a RTT?


I tried something like


container.meshes.forEach((mesh) => {

for (let i = 0; i < 5; i++) {
  const entries = container.instantiateModelsToScene(p => p + i);

  for (const node of entries.rootNodes) {
    node.position.x += (i + 1) * 10;

But though the instances are properly rendered on the main pass, they are not on the RTT.

you have to go through all meshes (not only the root nodes)

Thanks again. Working PG if anyone ever needs it:

1 Like

But this creates clones of the animated mesh, not instances. Which is bad if you have more than a few meshes. I have a whole army of soldiers that look the same, and I want to create ~50 instances of the original imported soldier, while ensuring that each instance has a separate animation. Is it even possible to solve this problem with instances, or should I just use clones and hope for good performance?

Not possible with instances directly. If you could live say 5 soldiers having the same animation, you could create 10 of them, with 4 instance as well for each.

It can be done with instances but you will need to do a bit of work: InstancedMesh With Separate Skeleton ??? - Questions & Answers - HTML5 Game Devs Forum (see last post)

1 Like

Thx, I will look into it. I am still a noob tho, so I will also try to think of some alternative solutions… in case this turns up to be as complicated as I think it is.
Recently, I also saw a demo of a babylon.js scene using WebGPU with 10,000 loaded meshes! I can’t wait for this to happen! I feel like this will definitely solve my problem, because I will just be working with clones and the performance will still be great :DD.

You can have a look at this as well: Vertex Animation Textures

1 Like