Home > Mobile >  Ignore collisions from all objects
Ignore collisions from all objects

Time:02-19

I am trying to check if there is a way to ignore collisions on an object completely. The object however will still have its rigidbody, but will not collide with anything. I know that Physics.IgnoreCollision is the way to do it but looks like I have to provide colliders from each object. What is the right way to do this?

Physics.IgnoreCollision(null, GetComponent<BoxCollider>());

CodePudding user response:

How about simply turning of its collider component?

GetComponent<Collider>().enabled = false;

Another alternative would be to configure a dedicated Layer, configure it in the Physics Settings -> Layer Collision Matrix to not collide with anything and temporarily assign that layer to your object

gameObject.layer = xy;
  • Related