- Home /
Trigger/Collider Questions
Hi! I've been testing a simple collision detection between a flattened capsule and a kinematic cube scaled to become some sort of platform.
I first used the default collider that came along with the capsule when I created the game object. I put in print() methods just so I'd know that the OnCollisionEnter and OnCollisionExit methods are called when the capsule hits the platform. For controls, I put in a basic AddForce to the capsule's Y-axis whenever the jump button is pressed. When running the code, I noticed that the OnCollisionEnter is called only once when the capsule hits the platform. After adding Y force (the OnCollisionExit is called) and allowing the capsule to drop down back to the platform, the OnCollisionEnter method isn't called anymore, no matter how many times I propel the capsule and allow it to land on the platform again.
I then turned to RaycastCollider, setting it to be a trigger, but similar to the collider I used earlier, it calls OnTriggerEnter once, and upon leaving the platform, it calls OnTriggerExit, then nothing else, even after a series of capsule jumps.
Any ideas what I may be missing in my setup? I tried adding and removing a rigidbody to the platform also, but no dice. Any help would be greatly appreciated. Thanks!
Answer by duck · Jan 28, 2010 at 11:51 AM
There's a specific setting in the console window which collapses identical messages down into a single entry - it's the "Collapse" button in the top bar of the console window.
Make sure "Collapse" is un-selected, and every print statement will appear on its own line, even if it's identical to others.
Answer by sulas · Jan 28, 2010 at 10:29 AM
Did you come to the conclusion that OnCollisionEnter is not being called again by the missing prints in the console?
I think it does not stack the same message up over and over so you might think that nothing's happening, try the "clear" button over the messages and jump again. Try something else, you can see in the editor maybe, like changing your object's z value by 10 or something obvious like that.
You're right. I didn't realize that the print messages stack on top of one another. Obviously I'm a super-noob. Thanks for the help! :)
Your answer
Follow this Question
Related Questions
raycasts only working with IsTrigger colliders? 1 Answer
Raycast 2D hits sprite with collider, but returns error when not hitting any collider 2 Answers
Raycast, Linecast, sphere collider or capsule collider? 0 Answers
active script from distance 3 Answers
Is there a way to detect if an object is being hit by a raycast? 2 Answers