- Home /
Ignore collisions between objects
Okay, so i have these robots, big robots, that i want to kill people when it gets near them, so i have a sphere that follows their feet. and it is scripted with the following instadeathcollider:
function OnTriggerEnter (col : Collider) { var player : FPSPlayer = col.GetComponent(FPSPlayer);
if (player) {
player.ApplyDamage(10000);
} else if (col.rigidbody) {
Destroy(col.rigidbody.gameObject);
} else {
Destroy(col.gameObject);
}
}
function Reset () { if (collider == null)
gameObject.AddComponent(BoxCollider); collider.isTrigger = true; }
How do i make it so it ignores the collision between the sphere and the robot ???? Physics.IgnoreCollision?
Please make sure you enter a proper title for your question, typing out something is "AL$$anonymous$$OST DONE ^_^" in all caps does not help anyone else here. Next time be sure to title your question more pertinently.
Answer by Loius · Oct 08, 2010 at 02:35 AM
Yes. Physics.IgnoreCollision is exactly how you'd ignore physics collisions between two objects.
Answer by Tetrad · Jun 24, 2010 at 02:33 AM
You could set up your robots with tags and then query whether or not the object you're colliding with has your robot tag. If it does, you early out.
http://unity3d.com/support/documentation/Components/Tags.html
Like this
function OnCollisionEnter(collision:Collision) { if(collision.gameObject.tag == "Robot") { Debug.Log("it's a robot"); return; }
// rest of your code
}
Your answer
Follow this Question
Related Questions
Why does my player object decide to ignore colliders whenever he feels like it? c# 1 Answer
Layers of collision in Unity (or something similar)? (C#) 1 Answer
Make a rigidbody collide with this rigidbody but not that one? 1 Answer
How to check if two objects are mutually ignoring collision? 0 Answers
Ignore collision for all except one 1 Answer