bool IsTrigger { get; set; }

robot_2Generated
code_blocksInput

Description

The IsTrigger property of the Collider class determines whether the collider behaves as a trigger. When set to true, the collider will not physically interact with other colliders but will still generate trigger events. This is useful for creating areas that detect when objects enter or exit without affecting their movement.

Usage

To use the IsTrigger property, simply set it to true or false depending on whether you want the collider to act as a trigger. When IsTrigger is true, you can handle trigger events using the OnTriggerEnter and OnTriggerExit properties to define actions when other colliders enter or exit the trigger area.

Example

// Example of setting a collider as a trigger
Collider myCollider = new Collider();
myCollider.IsTrigger = true;

// Define actions for when another collider enters or exits the trigger
myCollider.OnTriggerEnter = (collider) => {
    // Code to execute when a collider enters the trigger
    Log.Info($"Collider {collider} entered the trigger.");
};

myCollider.OnTriggerExit = (collider) => {
    // Code to execute when a collider exits the trigger
    Log.Info($"Collider {collider} exited the trigger.");
};