Deleting an object on collision.

I would like to delete my object if it collides with something. The problem is, the object is instantiated, and it may collide during instantiation. In other words, how can I delete an object if it is in a state of collision?

Normally you could set it a trigger, and in the OnTriggerEnter() function call Destroy(gameObject). Did you want it to destroy itself if it collides during instantiation? If not, you’d probably need to set some sort of flag and check that in OnTriggerEnter(). When the object is allowed to be destroyed, clear the flag.

On the off-chance that you meant that it collides between the line of code where you instantiate it and the line of code where you position it, you don’t need to worry about that.

You can use OnCollisionStay() if it’s already in a state of collision.