- Home /
Question by
Batzuga · Jun 23, 2014 at 08:24 PM ·
javascripterrorcollidertrigger
Script error: OnTriggerEnter
I'm getting a Script error.
"Script error: OnTriggerEnter
This message parameter has to be of type: Collider"
I have no clue why it gives an error like that. Any ideas?
Here's my script!
static var addgoal = 0;
var blockblue : Texture;
var blockgreen : Texture;
function Update () {
if(addgoal == 0)
{
renderer.material.SetTexture("_MainTex", blockblue);
}
if(addgoal == 1)
{
renderer.material.SetTexture("_MainTex", blockgreen);
}
}
function OnTriggerEnter (hit : Collision) {
if(hit.gameObject.name == "Sensor")
{
addgoal = 1;
}
}
Comment
Best Answer
Answer by dsada · Jun 23, 2014 at 08:32 PM
"This message parameter has to be of type: Collider""
You get the error so exactly it almost fixes itself. The OnTriggerX functions take Collider parameter type. The OnCollisionX functions get Collision parameter type. Sou you need to replace your Collision type in the parameter list to Collider