Objects pass through textures

My playground: https://playground.babylonjs.com/#1WR5BV

For some reason, my code opens the typescript compiler. Please copy all the code and paste it into the js compiler.

The essence of my task: the balls stand still. After some time, they should abruptly (with high speed) fly down. All objects are physical bodies, but some balls fly through textures due to their high speed. How can this be fixed?

Immediately I give the balls a mass equal to 0. After some time, I remove the balls with zero mass and create new ones with mass equal to 5. I couldn’t find another way to quickly set their speed after idle time.

 setTimeout(() => {
        lotto.spheresArray.forEach(item => item.dispose());
        lotto.createBalls(5);
    }, 3000);

I hope for your help

This is because your code follows the typescript structure. This is the JavaScript structure of a playground

no need to set up the engine

Also see https://doc.babylonjs.com/babylon101/first#the-playground

1 Like

Hi guys… 11116 welcome.

https://www.babylonjs-playground.com/#BXII#92

There’s a little physics demo, if wanted. It has GUI 2d buttons to test setMass(), applyImpulse(), applyForce(), setLinearVelocity() and setAngularVelocity().

Those are some of the most-used tools on BabylonJS mesh.physicsImpostor. At deeper, more-native-to-chosen-physics-engine levels… are mesh.physicsImpostor.physicsBody. PhysicsBody is not really part of BabylonJS, but has plenty of great tools, there, too.

BabylonJS-level physics docs here. Deeper “native level” physics docs might be on-web… depending upon which p-engine is chosen by programmer. BabylonJS has interfaces for three engines, I believe… OimoJS, CannonJS, and AmmoJS.

Possible helpful notes:

  • These physics engines run in JS, and at JS speeds. Collision testing happens at “stepped intervals”, and when an impostor is traveling too fast to be properly “collision tested”… it might “pass through” another impostor (that it was SUPPOSED-TO collide-with).

  • Slow down the impostor speeds and perhaps reduce large mass values.

  • Use boxes/boxImpostors instead-of planes/planeImpostors.

  • Learn about physics World scaling.

  • Learn to tweak physics step-speeds.

  • Spheres don’t have much/any friction (no surface area). Use damping methods to slow their roll.

Ok, maybe some of that stuff will help all the physics experimenters. Party on!

1 Like