- Home /
Collision Problem
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);
}
}
Comment
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?
Wiki
Answer by DryTear · Feb 26, 2013 at 12:15 AM
var objectName : string;
function OnTriggerEnter(col : Collider){
if(col.gameObject.name == objectName)
{
Destroy(col.gameObject);
}
}