0
votes

I am trying to define a layer for my rigidbody to ignore collision only from this layer. Can the layer to be ignored be named through script?

Current:

rb = GetComponent<Rigidbody>();
Physics.IgnoreLayerCollision(0, 11); //Layer number 11 = "Ignore Collision"

Target:

Physics.IgnoreLayerCollision("Ignore Collision"); //Layer number 11 = "Ignore Collision"
1

1 Answers

0
votes

You can use LayerMask.NameToLayer

Physics.IgnoreLayerCollision(LayerMask.NeToLayer("Default"), LayerMask.NameToLayer("Ignore Collision"));