onCollision scripting

I have a bunch of generated rigidbodies, all with the same script attached to them so they behave the same. When two collide i want to destroy them both and create one new rigidbody.

The problem I have is that it creates 2 new rigidbodies, because the script is attached to both colliding objects, and thus gets executed twice. Is there a simple way I can make something happen just the once in this context?

I thought that if i destroyed both in one iteration of the script then the script wouldn’t run for a second time, this does not appear to be the case however.

Cheers for your help.

LOL. I didn’t expect to solve this so quickly by myself…

Incase anyone wonders. Just putting this at the start of the onCollisionEnter does the trick:

if(c.gameObject.tag != "Body") return;
tag = "";

Where c is the Collision class received by the function. And all the rigidbodies with this script attached are all tagged initially as “Body”.