- Home /
onTriggerEnter not working?
My game has been coded so that when my ball reaches a capsule whose isTrigger property is checked, and is tagged Collectible the ball will fly upwards 100.0f.
void onTriggerEnter(Collider other)
{
if(other.gameObject.tag=="Collectible")
{
rigidbody.AddForce(0.0f,100.0f,0.0f);
}
}
However, when I tested it, the ball just passed through the capsule as if the code had no effect at all.
Help please?
Answer by Bunnybomb7670 · Feb 23, 2014 at 12:40 AM
void onTriggerEnter should be OnTriggerEnter
All of the Unity functions start with a capital letter, its good to remember that.
Thanks! The uppercase O worked! I'd think that it wasn't case sensitive.
Thanks again! I'll let you know if and when I finish the game.
@dsillman2000 - if your question is answered, please click on the checkmark to the left of the answer to close it out. Thanks.
Answer by SupremeRussian · Feb 23, 2014 at 12:40 AM
You seem to be missing a colon between Collider and other at the top. If that isn't it, then maybe the ball is traveling too fast for the collider to detect it. Try slowing it down.
Your answer
Follow this Question
Related Questions
Collider/trigger collision causing physics glitch 0 Answers
overlapsphere to destroy NPCs on exit 1 Answer
Collider Lifts me off Ground ??? And I'm afraid of heights !!! 1 Answer
Prevent shooting when gun is inside wall 1 Answer
Trigger Colliders: Is there a way to simulate a non-trigger collider? 0 Answers