- Home /
Checking for overlaping sprites in an array
Hi.
I have an array of sprites that are instantiated at random positions on the screen and I want to make sure that none of those sprites are on top of each other(since the player needs to press click them) I know I can use this somehow:
if (object1.renderer.bounds.Intersects(object2.renderer.bounds)) {
// Do some stuff
}
But I can't figure out how to implement it into a loop that checks it for all the sprites I have.
bump. Could really use some help from people who understands sprite bounds and calculating intersections with several objects
Answer by getyour411 · Mar 31, 2014 at 10:55 PM
http://answers.unity3d.com/questions/614080/checking-if-object-intersects.html
Take a look at OverlapSphere as your array feed
Your answer
![](https://koobas.hobune.stream/wayback/20220613141253im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How do i change a sprite when another gameobject with the same prefab is colliding / is near 1 Answer
How do i change a sprite when another gameobject with the same prefab is colliding / is near 1 Answer
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Store multiple sprite in code C# 0 Answers