Hello!
I am currently developing a 2.5D horizontal scroll platformer in StrangeLight Games. We have been using Unity for a while now and we have experienced some issues regarding trigger and collider detection not being as accurate as we needed. Until now these were not really important but we’ve come to a tougher situation recently.
In the caption below you can see in high poly, bumpmapped, with realtime shadows (just kidding, used some primitives :P) our configuration. Our character is the capsule object and the cube our enemy. When our player touches the enemy from above, the enemy dies, deactivating all of its colliders. We deactivate them in order to avoid the player from colliding with the bottom collider, which kills him.
[19642-captura+de+pantalla+2013-12-22+a+la(s)+17.15.11.png|19642]
Well, theory is simple but, In most cases our player dies and kills the enemy. That means there are few frames when our box enemy is dead, and alive at the same time, very Schrödinger cat’s like. The player should have deactivated its colliders but this takes some time, so our player manages to get through and touch the bottom collider before it has been deactivated.
Our player is using:
- Rigidbody in parent object, no
Gravity and is Kinematic - Character Controller
Our enemy is using :
- Rigidbody in parent object, no
Gravity and is Kinematic - Top and bottom Colliders in children,
set to triggers
We have been tweaking around with the Collision Detection and Gravity in our Character, but it still happens.
Should we be using Raycasting to check distance between our character and our enemy in order to deactivate colliders? Is there some other adjustment we can play with to obtain more accurate collision detection?