Sorry im at work and don’t have access to my code but basically. If i set it to destroy the “other” since nothing is destroyed until the end of the update both objects get flagged for destruction. I don’t care which one survives for right now just trying to understand the idea of how to do this. In the future i might create a new instance where the 2 hit but again then both would trigger the creation of a new instance and the 2 new instances would collide ect ect.
If you don’t mind which one survives then you could pick an arbitrary property on which to compare the two colliding objects - say, destroy the one whose transform has the highest y value, as follows (untested):
void OnCollisionEnter(Collision coll){
if(coll.gameObject.transform.position.y > transform.position.y) {
Destroy(gameObject);
}
}
Simply set a flag for destruction. This will destroy only the first object to run this code.
public bool isDestroyed;
void OnCollisionEnter(Collision coll){
if(!coll.gameObject.GetComponent<MyScript>().isDestroyed) {
isDestroyed = true;
Destroy(gameObject);
}
}