Question by
efirdc · Dec 21, 2016 at 07:36 AM ·
collisionrigidbody2dphysics2dfilter
Is there an easy way to make a RigidBody2D collide with only one other RigidBody2D?
I need to make a RigidBody2D collide with only one other RigidBody2D and ignore collisions with every other RigidBody2D.
Only way I can think is to call Physics2D.IgnoreCollision() for every other collider. Not exactly an elegant solution.
Comment
Answer by rettichmann · Dec 21, 2016 at 11:09 AM
You could try to tag both objects and ask if they collided or not.
void OnCollisionEnter (Collision col)
{
if(col.gameObject.tag == "mySpecialRigidBody2D")
{
// Do something.
}
}
Your answer
Follow this Question
Related Questions
Rigidbody2D and non-trigger child colliders! 2 Answers
Rigidbody2D.Cast() against mutiple colliders with a single Rigidbody2D 0 Answers
RigidBody becomes awake without a collision 1 Answer
2D collision without simulating rigid bodies 1 Answer
Do I need Rigid2DBody if I don't plan to use physics? 2 Answers