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.
void OnTriggerEnter(Collider other)
not
void OnTriggerEnter(Collision other)
Yes! Thanks so much for this. I was having the same problem and this fixed! :D
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.
You can't detect a 2d game object with OnTriggerEnter. It will never fire, and won't generate the error listed either. And the roll-a-ball tutorial is 3d!
Hey, I'm having this issue. I put 2D at the end, but it will say the error again but now "Script error: OnTriggerEnter2D. This message parameter has to be of type: Collider2D. The message will be ignored.
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.
If you had to specify the namespace, you certainly have a custom class all Collider on your project conflicting with Unity's class.
Are you sure your collider is on the object that this script is attached to? This looks correct script-wise.
– AddyarbAlso, check the name of the script. If the script has the name "Collider" then you need to change it.
– Addyarb