- Home /
Collider that can trip triggers that doesn't affect game physics?
I want to have some objects collide with a trigger. I could use a standard box collider but that effects collisions with the world and other objects. I don't want the collider to effect physics in any way, but still collide with the trigger. Is this possible and how?
edit: This is the code I have to detect collisions. I have this script attached to a box collider. I want the units I have tagged as enemy to collide with the trigger and get destroyed. The problem is that I can't use a standard box or sphere collider for the enemies because they have a big AI pathfinding script attached to them to control movement and adding a standard collider to them breaks their movement. They do have character controller attached to them so I am trying to collide with that.
function OnTriggernEnter (col : ControllerColliderHit)
{
if (col.gameObject.tag == "Ground Enemy" || col.gameObject.tag == "Air Enemy")
{
Debug.Log("enemy destroyed");
Destroy(gameObject);
}
}
Answer by getyour411 · Apr 11, 2014 at 12:34 AM
You have a typo above (TriggernEnter) so that might be affecting your testing; otherwise, just use layers per the doc
https://docs.unity3d.com/Documentation/Components/LayerBasedCollision.html
http://docs.unity3d.com/Documentation/ScriptReference/MonoBehaviour.OnControllerColliderHit.html
Search UA/Google for hundreds of examples, tuts, Q&A, etc.
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