- Home /
How to figure out the contact point of OnTriggerEnter?
I currently have a simple melee combat system set up, where there is a cylindrical melee trigger object attached to my player object's hand, with a rigidbody component and a collider. It is set to be a trigger, to not use gravity, and to be kinematic.
I want to instantiate a particle system at the point where the melee trigger object collides with my enemy, but I'm not sure how, because I'm using a trigger. If I try using OnCollisionEnter, and not using a trigger, all kinds of wonky things happen, because the physics of the collider is constantly bouncing off my player character, objects in the environment, and enemies.
Is there any way I can have it detect the point of contact, while still remaining a trigger collider that passes through colliders instead of bouncing off them with physics?
Answer by BoredKoi · Aug 27, 2010 at 04:36 PM
Have you tried using Physics.IgnoreCollision between your player and the melee weapon? That will take care of those collision events, and it would make sense (perhaps) for the weapon to interact with environment objects as well as enemies?
In any event, if you're using a Rigidbody Kinematic Trigger Collider as the weapon, then Rigidbody Colliders on the enemies should generate Collision.contactPoints for you? (i.e., generate the particle system from the perspective of the enemy not the weapon)
Interesting, didn't think of doing it that way. However, my enemy is using a CharacterController, not a rigidbody... so, I tried using OnControllerColliderHit, but it doesn't detect collision with my melee trigger object. If I turn off "Is Trigger" and "Is $$anonymous$$inematic", though, it does (but I need them). Does OnControllerColliderHit not detect collisions with Rigidbody $$anonymous$$inematic Trigger Colliders?