[Solved] Check collision with anything instead of just one object

I am making a city builder game and I wanted to know is there a way to check if an object collides with ANYTHING on the same layer (basically other objects like trees or roads)? I know you can just add it one by one but I don’t want my code to be bajillion lines long since I will add a lot of stuff later.
I have an object for display (so that you can see where it will be placed instead of placing it blindly) and I want to make it go red when you can’t place it there.
For now the only way I see is to make one condition for every object to check all the collisions.

This is how it looks like now only to check the collisions, it will only get worse because I plan on adding more stuff to the game.

I believe you could create a group, add all of the pertinent objects to the group and use the group name instead of all of the obiects seperatly.


I would have to test it to be sure… sometimes things don’t always work as expected when using instances. I’m not saying anything is broken, there’s just a method that’s not always obvious.

Edit: I tested this and it worked fine. All of the objects are in group, are draggable and have a “glow” effect named “EffectGlow” Since my example used the is being dragged I had to add a pick all objects because the drag condition “filtered” it to just the object being dragged.

Try it:

Thanks, it works very well and I figured out how to implement it into my project

1 Like