Enable physics for an added thin instance?

Hi everyone,

I think I have been doing whats in the “Instances” playground here (and there it works just fine).

But for some reason “my” thin instances get an offset on y.

Please see line 60 where I add the thin instance: https://playground.babylonjs.com/#88CB6A#172

Best wishes
Joe

This is weird. Let me take a look.

1 Like

Sphere is spawned on the cube face and pass through. Sphere.position.y value changed and that value is kept for all instances, giving on offset to all of them.

I think it’s more safe to create mesh with position at (0,0,0) and add an instance to keep root position unchanged.

1 Like

Thanks for looking into it :smiley:

I think I got it now: I understand the problem is that, if using thin instances, the root should stay at 0,0,0. But since I have to make root a physics body, it then changes the position of root - violating the 0,0,0-rule.

Why the 0-rule? Thin instances of root will get root’s position as offset right into their vertex data (once when creating). So as long as root is falling, I would have to correct the changes in position within the thin instance’s matrix. Since this is expensive, better keep root at position 0,0,0.

To achieve that on physics level I had to set mass to 0 when instantiating the physics body. Then when adding a thin instance set mass to 1 (or whatever) to that instance via the index parameter.

For some reason setMotionType did not work (STATIC to root, DYNAMIC to instances) :cry: