Collider
A base class of all colliders.
Read time 7 minutesLast updated 4 days ago
Definition
- Type: Class
- Namespace: UnityEngine
- Assembly: UnityEngine.PhysicsModule
- Inherits from: Component
public class Collider : Component
Remarks
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.
Additional Resources: BoxCollider, SphereCollider, CapsuleCollider, MeshCollider, PhysicsMaterial, Rigidbody
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. |
| 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. |