- Home /
The question is answered, right answer was accepted
Ignore Collision problem
Hello.
Currently I'm having a problem with 3D collisions.
One of my player characters has the ability to melt into water and pass through other characters. How can I implement this?
The only option I found so far was doing a Physics.SphereCastAll with a large radius (eg. 100) and ignoring collisions for the resulting colliders. Then, as the ability ended, I'd restore collisions again. However, this seems terribly inefficient. Is there a better way to do this?
Answer by ryanmillerca · Jul 15, 2019 at 10:12 PM
Hi @fa6ex, you can change the player's layer at runtime via gameObject.layer =
, then use the collision matrix to specify what layers collide with which other layers. Unity has some good documentation on this here: https://docs.unity3d.com/Manual/LayerBasedCollision.html