Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


detectCollisions

Determines whether other rigidbodies or character controllers collide with this character controller (by default this is always enabled).
Read time 1 minuteLast updated 6 days ago

Definition

  • Type: Property
  • Namespace: UnityEngine
  • Assembly: UnityEngine.PhysicsModule
public bool detectCollisions { get; set; }

Remarks

This method does not affect collisions detected during the character controller's movement but rather decides whether an incoming collider will be blocked by the controller's collider. For example, a box collider in the Scene will block the movement of the controller, but the box may still fall through the controller if detectCollisions is false. This property is useful to disable the character controller temporarily. For example, you might want to mount a character into a car and disable collision detection until it exits the car again.

Examples

using UnityEngine;public class Example : MonoBehaviour{ CharacterController controller; void Start() { controller = GetComponent<CharacterController>(); controller.detectCollisions = false; }}