Collision Problem (64226)

I got a box that suppose to get destroyed when it collides with the First Person Controller.

I get an Error:
Script error: OnCollisionEnter
This message parameter has to be of type: Collision
The message will be ignored.

What am I doing wrong? I put the script on the box. When the FPC touches it nothing happens.

function OnCollisionEnter (theCollision : Collision)
{
if (theCollision.gameObject.name == "First Person Controller")
{
Destroy (gameObject);
}
}

Nothing looks wrong with that. Double click on the error message you are seeing in the console so it jumps to the precise line of code. Perhaps you have more than one OnCollisionEnter and it's the other one that's wrong?

1 Answer

1

var objectName : string;

function OnTriggerEnter(col : Collider){
    if(col.gameObject.name == objectName)
    {
        Destroy(col.gameObject);
    }
}