Destroy 2 GameObject when Overlap

Hello guys I am working on 2D game and I want to destroy 2 GameObjects when they overlap and also player tap on then at that time. I did everything but i don;t have any solution for that. I need your help.

Break this into smaller problems that are easier to tackle:

  • How to tell when the user taps on an object? (There are various ways to do this, all involving a Collider2D and some involving a Physics2D.Raycast.)
  • How to tell when two objects overlap? (Again you’ll probably use Physics2D, though if your objects are roughly circular it might suffice to just check the distance between them.)
  • How to destroy the objects? (Object.Destroy or Object.DestroyImmediate.)

Tackle these one at a time, and let us know if you get stuck!

1 Like