Search code examples
c#unity-game-enginecollision-detection

In Unity can I allow the CharacterController.Move function to ignore collisions?


I'm using the CharacterController.Move function to move the player around the scene. I want the player to be able to pass through some objects under certain conditions. Is there a way to force the Move function to ignore collisions with other game objects when certain conditions are met in the script?


Solution

  • Physics.IgnoreCollision(SomeObject.collider, collider); 
    // collider is a CharacterController
    

    Or by using layers:

    Physics.IgnoreLayerCollision(layer1, layer2);