Instanced Physics Static Mesh

Hey,

I am experiencing some big issues with instances of physics meshes and collision.

It appears that with instanced meshes, there is no collision at all versions (and they do not show up in the debug viewer either?)

Could be a bug or could be an issue with my understanding?

Thanks for looking!

CC @Cedric

Instancing works. Check https://playground.babylonjs.com/#PX6E6C#25
I’m not sure to understand your PG or what you mean by there is no collision at all.

I am confused why there is no collision/physics mesh on my instanced objects (the boxes) they have a physics body/shape and I have called sync to match the number of instances - as far as I can see this is the same as your example, but I get no collision or debug visualisation when using the helper?

Anything in the console log?

Not unless you activate debug physics visualisation it shows:

Setting vertex data kind 'position' with an empty array

I assume this means that the actual physics instances are not created or something like that? I am unsure of why this could be.

yes, an error make the script to stop before physics creation. I don’t repro with the PG linked above.

1 Like

Ok I have worked out what is going on and how to explain what I mean.

So if you create the thin instances after already creating a physics body like so:

we can see that the physics objects just drop straight through the floor instead of colliding with the ground. https://playground.babylonjs.com/#PX6E6C#34

I have found that if we create at least 1 instance before adding the physics body then ensures proper collision, but going from 0 to >0 instances after body creation leads to no collision it seems.

(In my system I was making the physics and adding instances after but I will create 1 hidden instance for now)

Probably not a major thing but something to be aware of in case someone else hits this :slight_smile:

There should be atleast a warning for that and at least a line in the documentation.
Feel free to open a PR for that! I won’t be able to do it before a dozen days.

2 Likes