[solved] OnCollisionEnter triggers without collision?

I have a mesh with a collision primitive attached (box) and a player controllable rigidbody object with a spherical collider.

The mesh’s collision is set to IsTrigger, and it has a script containing a simple script (from the manual) with an OnCollisionEnter function to set an animation playing:

var player : GameObject;
var target : GameObject;

function Update () {

    OnTriggerEnter(player.collider);
}

function OnTriggerEnter (other : Collider)
{
Destroy(other.gameObject);
print("Collided");
target.animation.Play();
}

The player object is destroyed when entering the collision, so that much is working. However, the print message appears and the animation starts playing as soon as I hit Play in Unity.

Clearly I’m doing something wrong…but what?

By inserting the function OnTriggerEnter inside the Update() function it is being executed every frame. That means you are probably seeing the print executing continuously in the debug window. You dont need the OnTriggerEnter function inside the Update(). Hope that helps.

Gold star!

Muchos Gracias :slight_smile: