Hi, I was following the tutorial Roll-A-Ball. I kept getting this error:
Script error: OnTriggerEnter.
This message parameter has to be of type: Collider.
The message will be ignored.
I spent hours on checking where I did wrong, but still didn’t get it. It seems my OnTriggerEnter function never has been triggered. I checked the “Is Trigger” option in the box prefab. Please help!!!
In case anyone is reading this in 2019 and your problem isn’t that you’re using 2D objects, double-check that you did indeed use the word, ‘Collider’ as a parameter not ‘Collision.’ I couldn’t figure out my problem until I noticed I had used the wrong word. If you’re a newbie like me, this might have tripped you up.
This Error normally comes when u are trying to detect a 2D game object with
OnTriggerEnter(Collider other)
{
//Code inside
}
if you want to detect a 2D object you should have
OnTriggerEnter2D(Collider2D other)
{
//Code inside
}
hope this helps future persons,please remember OnTriggerEnter does not work for 2d objects detection,so if you are trying to destory a 2d object it will be OnTriggerEnter2D.
I tried removing the class reference in the parameter and that’s how I was getting the error, even though I had the UnityEngine directive at the top of my class definition.