Ammo plugin sphere impostor within another sphere impostor

Hello everyone, I’m trying to get this result : a sphere colliding within another bigger sphere ( like a lottery ball machine).

I guess opening the bigger sphere would do the trick but I wonder why the small sphere goes directly out of the big one ?

see this playground :

https://playground.babylonjs.com/#DGEP8N#16

Hi @David_Peeters,

This is because physics engines work with rigid full bodies and not only shells. which means - you can’t really put a sphere in a sphere. you can put a sphere in a mesh that is an empty shell.

Putting a sphere in a sphere is just like placing your character in a wall - the physics engine will calculate that as collision and will “throw” the object out, until the collision was resolved. Which usually results in the funniest physics interaction :slight_smile:

Thank you for your answer it helped a lot to figure how to slove this, here is how I did it:

https://playground.babylonjs.com/#DGEP8N#17

basically create another sphere within the first one, then merge both as one mesh and use BABYLON.PhysicsImpostor.MeshImpostor instead of BABYLON.PhysicsImpostor.SphereImpostor

3 Likes