check if gameobjects overlap when collision occurs help?

Hi everyone. Can someone help me with a JavaScript sample of how to check if one Game object prefab overlaps another At the point that a collision occurs?

Eg. Gameobject A,B, and C are overlapping each other in a 2d scene, and then game object D is moved in the direction and collides with game object A while it overlaps with B and C. Game object A,B, and C are all destroyed and a special effects prefab is instantiated at the point/position of the collision. Can anyone help me with coding this pseudo script concept?

29451-qaref.png

Is this what you mean? What collision are you wanting to look for? You want an object and anything it’s overlapping to be destroyed on collision? You Also say ‘point’, do you mean the point in space the collision happens or the point in time?

if that’s so I would try something like this.

//first add a OnCollisionEnter method to the script attached to the object you want to check for collisions. That will notify you when it collides with something and what it hit. I would write a seperate script/method that checks for whether your object is overlapping stuff.

function OnCollisionEnter2D(Collision col){
       if(the object you collided with has a certain tag e.g. "projectile"){
          do stuff then check for things the struck object overlaps      
          checkForOverlap(col.gameObject);
       }
       //i would do it that way so you can use colliders to detect overlap and also for the initial collision
}

GameObject[] : function checkForOverlap(GameObject){
     //In here you could find all the objects the initial object is overlapping also using colliders. In this case I would probably 
}

Let me know if you want clarification or if this helps at all!