How to work with the physics

Hi. I’m new to Defold.
I’m trying to wrap my head around the physics and such in the engine.

Imagine simple topdown billiard/pool or a minigolf game.
I have some 32x32 circle sprite, with Sphere dynamic collider (collider diameter = 32), and then some static rectangle walls, to bounce off of. Gravity is 0, 0, 0, since it’s a topdown view.

I’m playing around with the physics values, but I can’t find anything that would feel at least normal.
With the physics scale set to default 1.0, everything seems very slow.
With physics scale set to like 0.2 or less, it’s pretty good and fast, but the bounce angles seem to be completely wrong most of the time, and also wall-sticking is happening a lot when ball is launched at the wall at smaller angles.

I’m moving the ball with the apply_force message with single impulse force, and this is other thing that I don’t understand. Applying forces from 0 to like 500-1000 (vector3(600,600,0) for example), is making a difference, but then going over that to some crazy high values like vector3(1000000, 1000000, 0) is not making any difference anymore, it still feels the same like with the vector3(1000,1000,0). Is there any “max force/velocity” or something like that?

So I’m wondering if there’s something I’m doing wrong, or it’s all supposed to be like that.
Is it possible to create some billiard/pool or minigolf physics with the built-in stuff?

Thanks for any answer or advice here.

Physics scale of 1.0 doesn’t lend itself very well for games. The units used in the physics simulation is covered in this manual:

Our project templates have the scale set to 0.01:

This is discussed in this issue:

(I believe the fix of exposing valueb2_velocityThreshold should be quite easy to add if someone is interested in giving it a try!)

We have an issue in our backlog to improve dynamic physics simulation in 2D games:

1 Like