Collider
A base class of all colliders.
Read time 7 minutesLast updated 6 days ago
Definition
- Type: Class
- Namespace: UnityEngine
- Assembly: UnityEngine.PhysicsModule
- Inherits from: Component
public class Collider : Component
Remarks
Additional Resources: BoxCollider, SphereCollider, CapsuleCollider, MeshCollider, PhysicsMaterial, Rigidbody.
If the object with the Collider needs to be moved during gameplay then you should also attach a Rigidbody component to the object. The Rigidbody can be set to be kinematic if you don't want the object to have physical interaction with other objects.
Properties
Property | Description |
|---|---|
| attachedArticulationBody | The articulation body the collider is attached to. |
| attachedRigidbody | The rigidbody the collider is attached to. |
| bounds | The world space bounding volume of the collider (Read Only). |
| contactOffset | Contact offset value of this collider. |
| enabled | Enabled Colliders will collide with other Colliders, disabled Colliders won't. |
| excludeLayers | The additional layers that this Collider should exclude when deciding if the Collider can contact another Collider. |
| GeometryHolder | The structure holding the geometric shape of the collider and its type. (Read Only) |
| hasModifiableContacts | Specify whether this Collider's contacts are modifiable or not. |
| includeLayers | The additional layers that this Collider should include when deciding if the Collider can contact another Collider. |
| isTrigger | Specify if this collider is configured as a trigger. |
| layerOverridePriority | A decision priority assigned to this Collider used when there is a conflicting decision on whether a Collider can contact another Collider. |
| material | The material used by the collider. |
| providesContacts | Whether or not this Collider generates contacts for Physics.ContactEvent. |
| sharedMaterial | The shared physics material of this collider. |
Methods
Method | Description |
|---|---|
| ClosestPoint | The closest point on the collider given a specified location. |
| ClosestPointOnBounds | The closest point to the bounding box of the attached collider. |
| GetGeometry | Returns the geometric shape of the collider of the requested type. |
| OnCollisionEnter | OnCollisionEnter is called when this collider/rigidbody has begun touching another rigidbody/collider. |
| OnCollisionExit | OnCollisionExit is called when this collider/rigidbody has stopped touching another rigidbody/collider. |
| OnCollisionStay | OnCollisionStay is called once per frame for every Collider or Rigidbody that touches another Collider or Rigidbody. |
| OnTriggerEnter | Called when a Collider with the Collider.isTrigger property overlaps another Collider. |
| OnTriggerExit | OnTriggerExit is called when the Collider other has stopped touching the trigger. |
| OnTriggerStay | OnTriggerStay is called almost all the frames for every Collider other that is touching the trigger. The function is on the physics timer so it won't necessarily run every frame. |
| Raycast | Casts a Ray that ignores all Colliders except this one. |
Inheritance
Operators
Operator | Description |
|---|---|
| operator == | Compares two object references to see if they refer to the same object. |
| bool | Determines whether the object exists. |
| operator != | Compares if two objects refer to a different object. |