- Home /
Trigger not being activated?
[2D] So, I'm working on a platformer-type game with jumping and stuff. I have the jump worked out, and it works just how I want, but I need to find out a way to refresh the jumps upon landing. I made an invisible box with a Box Collider 2D that is a trigger. However despite this, my script has a hard time seeming to be able to figure out when it is grounded or not. It seems like my OnCollision's are not being triggered ever, as the print always says false. Any tips?
(the 'jump arc' is the one I like, 'jump arc try 2' was an attempt to see if I could fix it.)
I'm really stuck on this, so if you guys could help me out, that would be much appreciated.
Answer by MightyBearGameStudio · Dec 29, 2017 at 06:49 AM
void onCollisionEnter () {
}
should be changed to:
void OnCollisionEnter(Collision col) {
}
same with the oncollisionstay and exit.
Hmm, I'm not sure I understand. I think I did it right (I tried it both with and without checking for tag, which my trigger definitely has) and it still always prints that I am not grounded, and also restricts my jump (this jump is just a testing one and therefore isn't an arc).
The OnCollisionEnter has to have a capital O, it's very case sensitive.
Also, you need the "Collision col" in the parenthesis of the OnCollisionEnter void, or else it doesn't work. Tell me if it works!
I finally got it to work! The issue ended up being so dumb in retrospect. I didn't realize I had to make sure it was a 2D OnCollision. Once I changed them to OnCollisionEnter2D(Collision2D col)
it worked! Thank you for your help!