Any sense in trying to use the native physics for 2d?

I don’t notice any two axis sliding joints in the documentation (which would be the easiest way to accomplish 2d in a 3d engine), but I figured I’d ask if anyone had used the native babylonjs physics for 2d simulation. If not, has anyone had a good experience with any 2d js physics libraries?

Pinging @trevordev who developed some of our latest physics support.

And by the way, Welcome to the forum

Hey and welcome.

I probably wouldn’t recommend using the built in 3D physics for 2D as that might be a bit overkill and may produce unexpected behavior but it might be ok if you have a simple use case.

If you scenario is really simple (everything is tile based, no rotation, aabb collision is all thats needed) I would try to do the calculations manually so you know exactly what is going on.

For more complex cases I’ve used box2Djs ( a bit in the past which worked pretty well but matterJS looks the most popular right now Matter.js - a 2D rigid body JavaScript physics engine . You should be able to create a physics world using one of those libraries and sync the state with babylon the same way the 3D physics plugins work

Hope this helps


Thanks! I’ll check those out. Right now I’m using circles to check collision and basic physics for movement. Stuff does not really need to bounce off other stuff in my use case, it’s just that the math to hand-implement ray casting would be kind of hairy.