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

**URL:** <https://forum.defold.com/t/what-is-the-correct-way-to-implement-pushing-objects-away-from-each-other/74352>\
**Category:** Questions\
**Created:** [October 2, 2023, 4:23pm UTC](https://forum.defold.com/t/what-is-the-correct-way-to-implement-pushing-objects-away-from-each-other/74352 "2023-10-02T16:23:52Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Regven](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/regven/32/32919_2.png) [@Regven](https://forum.defold.com/u/Regven)\
**Post date:** [October 2, 2023, 4:23pm UTC](https://forum.defold.com/t/what-is-the-correct-way-to-implement-pushing-objects-away-from-each-other/74352/1 "2023-10-02T16:23:52Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [October 2, 2023, 7:07pm UTC](https://forum.defold.com/t/what-is-the-correct-way-to-implement-pushing-objects-away-from-each-other/74352/2 "2023-10-02T19:07:28Z")

</div>

> [@Regven](#):
>
> dynamic objects

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

---

<div class="post-metadata">

**Author:** ![Regven](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/regven/32/32919_2.png) [@Regven](https://forum.defold.com/u/Regven)\
**Post date:** [October 3, 2023, 12:21am UTC](https://forum.defold.com/t/what-is-the-correct-way-to-implement-pushing-objects-away-from-each-other/74352/3 "2023-10-03T00:21:47Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![Regven](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/regven/32/32919_2.png) [@Regven](https://forum.defold.com/u/Regven)\
**Post date:** [October 3, 2023, 11:57pm UTC](https://forum.defold.com/t/what-is-the-correct-way-to-implement-pushing-objects-away-from-each-other/74352/4 "2023-10-03T23:57:35Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![benjames171](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/benjames171/32/34759_2.png) [@benjames171](https://forum.defold.com/u/benjames171)\
**Post date:** [October 4, 2023, 12:13am UTC](https://forum.defold.com/t/what-is-the-correct-way-to-implement-pushing-objects-away-from-each-other/74352/5 "2023-10-04T00:13:51Z")

</div>

You could manually apply a force to each object after detecting a collision using the [apply\_force](https://defold.com/ref/beta/physics/#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.

---

<div class="post-metadata">

**Author:** ![Regven](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/regven/32/32919_2.png) [@Regven](https://forum.defold.com/u/Regven)\
**Post date:** [October 4, 2023, 5:02am UTC](https://forum.defold.com/t/what-is-the-correct-way-to-implement-pushing-objects-away-from-each-other/74352/6 "2023-10-04T05:02:11Z")

</div>

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.
