Collision not triggering

Hello all.

I know there is a topic just like this but my example is different so i wanted to make a new post.

I have a object smallblock.
That have collision.

Its everytime the same block with just a different animation.

When i use the single condition to check collision. The draw circle is only activation 1 time when block 1 gets in collision with block 2.

But not for the other collisions

But when i use the repeat for every instance
Its not even registering the collision anymore.

Hi, to handle instance parameters in expressions correctly you need to use a for-each loop.
If you change the way you display whether instances are in collision, for example by changing the color, you will notice that it works, otherwise you need to create a for-each loop and only then create a shapepainter.

  1. It works correctly:
    image

  2. This does not work correctly because the program does not know in the coordinates of which specific instance to create an object, since several of them are in collision at the same time:
    image

  3. This works correctly because we loop through each instance that is in collision and create an object at the coordinates of each one:

Please note that in examples 2 and 3 objects are created every frame, which is not good. To optimize, you need to figure out how to create only one object for each instance or delete unnecessary ones. For example, you can link objects and check if there are any linked objects before creating a new one:

Thanks this is a great example!!!

I let you know if i get it to work :grinning:

1 Like

When you use ‘Repeat for each instance of an object’ in GDevelop, it focuses on one object at a time in each loop. That means other instances of the same object are temporarily ignored. So, if you’re checking for a collision, the object might end up checking if it’s colliding with itself, which won’t work as expected.

1 Like

Have some great news!!

I have it working just need to recreate it for al 3 checkers.
But i got the solution with the action pick.

It was strange that “pick block closest to” dint give the same results.

Happy that i got it working using the same block with 3 types animations instaid of 3 types of block instances


I wrote:

Your “pick closest to” condition is only working with the current smallblock of the repeat event. That’s why it wouldn’t have worked - the other smallblock objects are not in GDevelop’s reference list of smallblock objects.

The “Pick all instances” will change the reference list to include all the smallblock objects, not just the one current for the repeat event.

This kind of information would be verry usefull to have documented.

Or is it and i have missed it?

I call upon your help once more.

so this function where its checking if the checker point is inside the group blocks
works for all group items exept if its the same type as own instance,

So when its a wood block or a glass one it get triggers but when its a stone one its not getting triggerd at all.

I dont understand why its not seeing that even if its part of the group

Because the first condition tells GDevelop to only work with the SmallSquareStone objects that have a timer >= 1 second. So those will be the only SmallSquareStone objects that will checked when you refer to them as blocks members.

To get around this, add a “Pick all instances of blocks” condition before the check for checker point inside blocks.

Thanks

I have it working.

I still need to test it on pc with debugger on

Because at some point it stop working i need to see if that has to do with the amount of blocks


But for now its good enough to work on the rest of the game.

Time to work towards the playable versions