What is the correct way to implement pushing objects away from each other?

There are two dynamic objects and I’m not quite sure how to make them spring nicely from each other.

That is A → ← B ====> A <---- ---->B

Preferably the repulsion characteristics would be customizable.

Restitution - does not help, with a high value of mobs just landing started jumping, as if they want to escape from the game.

Dynamic objects should resolve collisions automatically. What kind of behaviour are you looking for?

I want two dynamic objects to bounce away from each other when they collide. It is desirable to be able to customize the range of bouncing. I chose the dynamic object because it already has the concept of weight and collision, but I don’t know how to give the desired effect (i have already tried experimenting with the parameters, but it did not bring much result).

I may have expressed it incorrectly, so I’ll rephrase the question

How to increase the repulsion of dynamic objects when they collide ? Right now they just collide and push each other, is it possible to make them repel each other by a distance ?

You could manually apply a force to each object after detecting a collision using the apply_force message.

Otherwise you might get better results writing your own kinematic physics. Defold uses Box2D for it’s ‘automatic’ physics and sometimes that isn’t flexible enough to get the desired result.

1 Like

Thank you very much ! Probably just my query just didn’t fit the Box2D physics, but since I’m a newbie I thought it was me doing something wrong.