# How to delay collision processing (SOLVED)

**URL:** <https://forum.defold.com/t/how-to-delay-collision-processing-solved/65209>\
**Category:** Questions\
**Created:** [May 20, 2020, 8:48am UTC](https://forum.defold.com/t/how-to-delay-collision-processing-solved/65209 "2020-05-20T08:48:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![TillCity](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/tillcity/32/20599_2.png) [@TillCity](https://forum.defold.com/u/TillCity)\
**Post date:** [May 20, 2020, 8:48am UTC](https://forum.defold.com/t/how-to-delay-collision-processing-solved/65209/1 "2020-05-20T08:48:23Z")

</div>

Suppose I have a collision between two different sprites, A and B. The two are somehow “different”. I do not mean visually but have attributes that give them special characteristics. For arguments sake let us say that they both have a “weight” with B being heavier than A (the actual criteria I want to use are rather more complex but the principle remains the same)

In my own case when the two collide I want to change their linear velocities. However, the way in which the velocities of A (lighter particle) changes depends on the way the velocities of B (heavier particle) change.

What is not clear to me is this - from what I can see both A and B get the _collision\_response_ message , and so it should be. What I need to do is to be sure that the collision response for A (lighter) is handled **AFTER** I have successfully created the collision response for B (heavier). How do I go about doing this in a foolproof way?

From what I can see whether A gets the message first or B is haphazard. If each goes about processing its messages entirely oblivious of the other than I cannot ensure the response pattern I am after.

---

<div class="post-metadata">

**Author:** ![Mathias\_Westerdahl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/mathias_westerdahl/32/228_2.png) [@Mathias\_Westerdahl](https://forum.defold.com/u/Mathias_Westerdahl)\
**Post date:** [May 20, 2020, 9:42am UTC](https://forum.defold.com/t/how-to-delay-collision-processing-solved/65209/2 "2020-05-20T09:42:53Z")

</div>

The order of which the messages come is up to the physics engine.  
Since each message also provides info about the _other_ object, you should be able to filter the messages like so:

Some pseudo code:

```lua
if get_mass(message.id) < get_mass(message.other_id) then
    return
end
-- now we know we only handle the collision once
-- and that the mass of `id` is larger than `other_id`
resolve(message.id)
resolve(message.other_id)

```

---

<div class="post-metadata">

**Author:** ![TillCity](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/tillcity/32/20599_2.png) [@TillCity](https://forum.defold.com/u/TillCity)\
**Post date:** [May 22, 2020, 8:08am UTC](https://forum.defold.com/t/how-to-delay-collision-processing-solved/65209/3 "2020-05-22T08:08:47Z")

</div>

Thanks
