Hey guys,
I’m having an issue where my character models aren’t correctly updating their bounding boxes. The character models are cloned skeletons and meshes that are animated (animations work perfectly), and when I use the mesh.refreshBoundingBox(true) method to update the bounding info for picking, the results will only be correct when all of the character models are performing the same animation. When the animation for one character changes, then the bounding box is distorted for any mesh doing a different animation.
I’ve been working on reproducing it in a Playground, and came across this: Use Bones and Skeletons - Babylon.js Documentation
It has an example where each mesh has a new skeleton cloned just for it:
dudes = [];
for (i = 0; i < 10; i++) { // 10 clones
var xrand = Math.floor(Math.random() * 501) - 250;
var zrand = Math.floor(Math.random() * 501) - 250;
var c = [];
for (j = 1; j < newMeshes.length; j++) {
c[j] = newMeshes[j].clone("c" + j);
c[j].position = new BABYLON.Vector3(xrand, 0, zrand);
c[j].skeleton = newMeshes[j].skeleton.clone();
scene.beginAnimation(c[j].skeleton, 0, 120, 1.0, true);
}
dudes[i] = c;
}
I’m wondering if it’s necessary to clone a new skeleton for every single mesh and then run the same animation on each skeleton? It seems like you should use a single skeleton (for each entity) for all of the sub meshes and just animate it once.
I have no idea if this is the cause of my problem either, so any ideas in that regard would also be super helpful! (Working on a PG)