Unwanted occurence of collision event

Hi,

44394-unwantedcollision.png

The picture above demonstrates what I want to achieve. Let me explain what this is all about and which part does not work as expected.

A, B are two GameObjects that are moving towards the direction of the arrows.
Block1, Block2 are also GameObjects, stationary, both having rigidbody and a box collider.

Both A and B have a script attached on them that detects collision. Once collision occurs (OnTriggerEnter()), the object is destroyed.

Upon initialization, the script is disabled for A, because I do not want it to collide with Block1 (this is a temporary solution until I find what’s happening).

An IEnumerator moves A and B towards the direction they’re supposed to go. Now, although A’s script has been disabled, it sometimes collides with Block1, getting itself destroyed. Other times it will go on as intended. If A still had the script enabled, this would make perfect sense. Testing the inspector during runtime, the script is indeed disabled.

Block1, Block2 have no script attached to determine what happens upon collision.

Any ideas on why this weird thing’s happening?

Whether a script is enabled or disabled only affects the OnGUI(), Update(), FixedUpdate() and LateUpdate() methods (correct me if I forgot one). Every other callback is executed. You can use a bool to check if your GameObjects should be destroyed or not.