OnCollisionEnter seemingly triggers twice instantly on Instantiated objects.

Edited to hopefully show up in more responses: I have a script that is intended to check an objects tag upon any collision and if it meets my conditions then destroy both objects and spawn in a new bigger one in the same place as the first object that collided. My problem is that instead of two smaller objects becoming one larger one as intended, I end up with two larger ones.

function OnCollisionEnter(hit : Collision) {

bubChangePos = this.transform.localPosition; //the position to spawn at.

if (bubSize == 0 && hit.gameObject.tag == "Bubble0")
	Instantiate (bub1Prefab, bubChangePos, Quaternion.identity);
	bubSize = 1;

I thought that the bubSize var would stop it from triggering again since it would no longer be 0 but that and a bunch of other checks and balances I've tried have failed. It seems like it's going to call OnCollisionEnter twice no matter what.

Please help out with this specific script and be succinct. If I get a JavaScript answer that solves my issue I will happily mark it as solved and upvote it if you can refrain from using the words "simple", "simply", and the phrase "Mouthbreathing Idiot!". :)


If the script is attached to both objects, it will be run twice when the collide, once on each object, because each object detects the collision independently. Try checking not just the bubSize of the object the script is, but also the bubSize of the other object.