- Home /
Can not get OnTriggerEnter and OnCollisionEnter to work!?
I have two objects with colliders and one with a rigid body. Here are their inspector settings.
This first is the cube, which has the rigid body and is moving during the collision.
Second here is the plane that the cube is colliding with
I am using a simple script just to print a debug if there is any collision. This script is inside the cube object.
void onCollisionEnter(Collision collision){ Debug.Log (collision.gameObject.name); }
I have searched through the documentation for hours, and I appear to be doing everything correct, but there is no collision.
Any help is appreciated. Thanks so much.
Answer by tanoshimi · Sep 26, 2016 at 05:01 PM
Because case-sensitivity matters. The method is called OnCollisionEnter(), not onCollisionEnter().
Wow! Thanks. I didn't realize OnCollisionEnter was particular about that. $$anonymous$$aybe i just skipped over that in documentation.
It's nothing particular to OnCollisionEnter. All method names in C# and Javascript (and, in fact, in almost all modern program$$anonymous$$g languages) are case-sensitive.