Bounce objects which are colliding

hello all,

I see that many already faced this issue but I haven’t found the answer, so here I am.
I have different objects, but in the same group. They move around and collide.
On collision, I’d like them to bounce off each other.
I tried to create a second group to manage this, hoping that instance picked would be linked to the appropriate group used in the collision, without success:

I don’t know how to pick both instances and apply the bounce behavior to each of them.

Any ideas?


I should try this myself to give you a better solution, but have you tried to do a for each object and remove the trigger once?

I’ve tried without success.
I need both references anyway as A is bouncing off B.

The issue is that Players and PlayersBounce refer to the same instance :frowning:


If someone can help me here :slight_smile:

So Players and PlayersBounce is the same instance? …do you mean its 2 copies of the same object?

If so, what you need is to get rid of “Trigger Once” and make object variables.
Also, you can just put everything into one group i think.
Then you do…

For example…

Repeat for each “Players”
If “Players” is in Collision with “Players”
If “Players” Boolean variable “Bounce” = False

Change “Players” boolean variable “Bounce” = True
Bounce “Players” off "Players

Then to change the boolean back you do

Repeat for each “Players”
If “Players” is in Collision with “Players” (Inverted so that its Not in Collision)
If “Players” boolean variable “Bounce” = True

Change “Players” boolean variable “Bounce” = False

Somthing along those lines should work.

The key to making it work is using “For each object” paired with Object variables, and dont use Trigger Once.

Thanks, indeed, the objects are the same. I could use “Players” instead of “PlayersBounce”.

Regarding your proposal:
Bounce “Players” off "Players
→ won’t it pick the same object?
How does it know which is which?
This is the issue I’m facing.

Because, by using the “For each Object”, you creating individuality among objects, even if they are copies of each other…

…then by adding “Object Variables”, your giving each objects their own… sort of “ID”, that way GDevelop can now distinguish between the objects.

Try it the way i explained, it should work, if it dosent let me know and we can adjust it, but im fairly certain we can make it work.

I just spent the last 2 hours trying to make this thing work…

Conclusion… im fairly certain this extension isnt ment to be used this way…

I can make one of the players bounce off another, but not both at the same time, at least not with the extension.

You have to use your own events using forces, then on collision youd have to add oposite forces to each object in steps using variable to distinguish between the two.

What you want can be done, just not with this extension.

Thanks for your efforts and time spent.
It’s a pity that it cannot be used this way :frowning:
Picking instances seems to have room for improvement.