I have 10 objects in a group (shapeGroup) and I want to test each object to see if it is in a collision state with any other object when the mouse button is released. So far I have come up with the following:
(sorry, cut off some code here - doElse is initialized to 1 before this section)
I would much prefer to do this using a For Each loop, but I can’t seem to find the correct action syntax that will let me pass one object at a time to a function that contains code similar to the above. It has to be an object pass, because the collision event requires two objects.
Hey folks, I’m sort of stuck here. I’ve been trying to come up with a solution that minimizes coding, but I can’t seem to get the For Each to work properly with a group of objects. Here is the function I created:
The logic is very simple - if the shape specified in _ PARAM1_ is colliding with any shape in _ PARAM2_ , change the animation to “collide”. The tempDebug is a text block in the scene.
In the following code, the first 2 actions are calls to the function using a hardcoded shape - both of these work properly.
The For Each logic doesn’t work - no matter what I try, I can’t seem to figure out how to pass one object of the group AND the entire group to the function. I even went as far as to create 2 groups for the objects. The first (shapeGroup) contains all the objects and is referenced in the For Each. The second (shapeCollide) contains the same objects as shapeGroup, but isn’t referenced by the For Each logic.
Is what I am trying to do impossible with GDevelop or am I missing something regarding For Each loops.
When I read the OP, I tried to reproduce it (without a function), and I didn’t succeed either.
I think the problem is that the compared object belongs to the group to which it’s compared.
Your sentence says “is overlapping any other shape in …” - How do you translate that other?
When I tried the same with two groups, each containing different objects, it worked fine.