OnTriggerEnter doesn't work
I'm currently using this for when the object collides with another object:
void OnTriggerEnter(Collider2D other)
{
if(other.tag == "Player")
{
hitPlayer = true;
}
}
Unless that way I scripted that is wrong then I really have no idea what is going on.
Basically no matter what I do, that function won't go off despite colliding with the player. The object holding that script has been set to a trigger with both objects having a rigidbody. Their collides are both big enough to collide with each other but that OnTriggerEnter function just won't run and I really don't know why.
Is there something else I've forgotten about when using OnTriggerEnter as it's worked all the other times I've used it.
Take a look at the docs and examples. Just read closely and you'll see the problem. This Unity page might help. It lists them all -- can click each one for examples:
http://docs.unity3d.com/ScriptReference/$$anonymous$$onoBehaviour.html
Well... XD. It works now.
It's funny as I'm pretty sure I tried that awhile ago and it didn't work. $$anonymous$$ust of typed it wrong.
Thanks anyway
Your answer
![](https://koobas.hobune.stream/wayback/20220612071233im_/https://answers.unity.com/themes/thub/images/avi.jpg)