Colliders on instantiated gameobjects

Hi guys,

I'm spawning a couple trees ramdomly on a map but I would like delete them in case they spawned on top of each other but my colliders don't seem to be working right. What's the right way of checking if a tree is colliding with another one when spawning it?

This is my spawner code:
3844873--324958--upload_2018-11-1_11-45-8.png

This is the script I tried to use in each tree to check for collision:
3844873--324961--upload_2018-11-1_11-45-50.png

Thanks guys!

void OnTriggerEnter(Collider other)

"other" is the the other object that has collided with this object. All you need is a way of identifying whether this "other" object is a tree GameObject.
You can do this however way you wish, usually it's done by comparing the name or tag.

For example:

void OnTriggerEnter(Collider other) {
   if(other.gameObject.CompareTag("tree")) {
      //A collision with a tree object has been detected.
   }
}