Description
The Touching
property of the Collider
class provides a list of colliders that are currently interacting with this collider. The behavior of this property depends on whether the collider is set as a trigger or not:
- If the collider is a trigger, the
Touching
property will list all colliders that are currently touching the trigger.
- If the collider is not a trigger, the
Touching
property will list all triggers that this collider is currently touching.
Usage
To access the Touching
property, you need to have a reference to a Collider
instance. You can then iterate over the collection of colliders that are touching or being touched by this collider.
Example usage:
Collider myCollider = ...; // Assume this is your collider instance
foreach (Collider touchingCollider in myCollider.Touching)
{
// Perform operations with touchingCollider
}
Example
Collider myCollider = ...; // Assume this is your collider instance
foreach (Collider touchingCollider in myCollider.Touching)
{
// Perform operations with touchingCollider
}