Apply impulse in 2D Physics?

Hello!

I’m trying to port a Unity game to Defold, it relies heavily on the physics engine, which fortunately is Box2D in both.

In Unity, we use a lot ForceMode2D.Impulse, which I guess translates to ApplyLinearImpulse

But in Defold, I only see apply_force

I believe I could maybe set linear_velocity taking into account the mass of my rigidbody, but I’d rather let the physics engine set the final velocity of the rigidbodies.

What do you think ? Shall I try to contribute by adding a new message in Defold to trigger ApplyLinearImpulse ? (No idea of the complexity of doing this, I don’t know enough Defold yet!)

1 Like

I don’t know if this will work or not, or the details of how to do it… There is a box2d Asset which can be used to replace the built it Box2D. This might have what you need, it contains functions with impulse in the name:

1 Like

Thank you, I’ve seen this library, but I’d rather not have to go that low level, micromanaging physics in my code and lose all benefits of using an editor (it replaces the builtin Box2D) for a basic feature like applying an impulse :slight_smile:

1 Like