Strange physics behavior (SOLVED)

Hi there,

it seems to me that there is something strange with physics. It is extremely basics and I have a possible explanation but no viable solution. I have to say that I am not an expert in physics in Defold; and I am not an expert in Box2D nor in numerical analysis. [See also the post “Strange behavior when applying force” of @pawel.jarosz21.]

In the small attached repro 6 identical go’s with a collision object of type dynamics is created at different x positions. In init a force is applied at any go’s: all the forces have the same Y component but different X components.

After 5.0 seconds the go’s are deleted and the final variations of the Y position are printed in the console. The physics says that all these DY must be equal since the Y components of the applied forces are all equal.

However, in the repro, the DY are different.

I think that this is an approximation problem. The forces are too big and some numerical errors propagate in the simulation resulting in the different DY. Note also that the project has a custom gravity of -100.0 in the Y direction.

So one would like to lower the forces and also lower the gravity (for example to the default -10.0). And indeed with low values of forces and gravity the DY’s are all equal. But THEN the animation is really slow… as the dt of the physical simulation was way to small.

Hence the question is: how to get a non-slow-motion physics simulation with “low values” of forces in order to avoid the numerical errors?

I hope I have been able to explain the point.

Ciao, Rocco.

defold_test_physics.zip (35.1 KB)

3 Likes

Not in front of a computer right now, but have you tried changing the physics scale in game.project?

1 Like

As @britzl suggested setting scale to 0.1 solve the problem.

If I understand correctly the scale 1 pixel = 1 meter is too high for Box2D, hence the numerical errors. Setting the scale to 0.1 improve the simulation.

And so I learned something new and Newton was right in claiming F = ma. :smile:

Thanks!

1 Like