How would I check if there are a certain number of objects next to each other?


I have an object that I would like to perform a certain action, only if there are two or more instances of the same object next to each other (say under 100 pixels). What’s the best way to do this? I’ve tried different things and can’t get it to operate as smoothly as I like.

Thanks so much if anyone has experience with this type of thing!!


You could create a circular sprite that is 200 pixels in diameter, place it where your original object is, and see how many of objects the same as the original object it collides with (I think “Number of Objects” will do this for you once you check for collision).


Thanks! However, doesn’t number of objects check for the universal number, or does the check conform to the above check parameters?


If you use it as a subevent of the collision detection, I think it returns the number of objects that match the collision conditions (i.e. how many are included in the collision). Try it out and see.


Thanks, this is a good idea. Will try it out and report back.