class in UnityEngine
/
Inherits from:Collider2D
/
Implemented in:UnityEngine.Physics2DModule
Collider for 2D physics representing an arbitrary set of connected edges (lines) defined by its vertices.
Additional resources: BoxCollider2D, CircleCollider2D, PolygonCollider2D.
| Property | Description |
|---|---|
| adjacentEndPoint | Defines the position of a virtual point adjacent to the end point of the EdgeCollider2D. |
| adjacentStartPoint | Defines the position of a virtual point adjacent to the start point of the EdgeCollider2D. |
| edgeCount | Gets the number of edges. |
| edgeRadius | Controls the radius of all edges created by the collider. |
| pointCount | Gets the number of points. |
| points | Get or set the points defining multiple continuous edges. |
| useAdjacentEndPoint | Set this to true to use the adjacentEndPoint to form the collision normal that is used to calculate the collision response when a collision occurs at the Edge Collider's end point. Set this to false to not use the adjacentEndPoint, and the collision normal becomes the direction of motion of the collision. |
| useAdjacentStartPoint | Set this to true to use the adjacentStartPoint to form the collision normal that is used to calculate the collision response when a collision occurs at the Edge Collider's start point. Set this to false to not use the adjacentStartPoint, and the collision normal becomes the direction of motion of the collision. |
| Method | Description |
|---|---|
| GetPoints | Gets all the points that define a set of continuous edges. |
| Reset | Reset to a single edge consisting of two points. |
| SetPoints | Sets all the points that define a set of continuous edges. |
| Property | Description |
|---|---|
| enabled | Enabled Behaviours are Updated, disabled Behaviours are not. |
| isActiveAndEnabled | Reports whether a GameObject and its associated Behaviour is active and enabled. |
| attachedRigidbody | The Rigidbody2D attached to the Collider2D. |
| bounciness | Get the bounciness used by the collider. |
| bounds | The world space bounding area of the collider. |
| composite | Get the CompositeCollider2D that is available to be attached to the collider. |
| density | The density of the collider used to calculate its mass (when auto mass is enabled). |
| errorState | The error state that indicates the state of the physics shapes the 2D Collider tried to create. (Read Only) |
| friction | Get the friction used by the collider. |
| isTrigger | Is this collider configured as a trigger? |
| offset | The local offset of the collider geometry. |
| shapeCount | The number of active PhysicsShape2D the Collider2D is currently using. |
| sharedMaterial | The PhysicsMaterial2D that is applied to this collider. |
| usedByComposite | Sets whether the Collider will be used or not used by a CompositeCollider2D. |
| usedByEffector | Whether the collider is used by an attached effector or not. |
| gameObject | The game object this component is attached to. A component is always attached to a game object. |
| tag | The tag of this game object. |
| transform | The Transform attached to this GameObject. |
| hideFlags | Should the object be hidden, saved with the Scene or modifiable by the user? |
| name | The name of the object. |
| Method | Description |
|---|---|
| Cast | Casts the Collider shape into the Scene starting at the Collider position ignoring the Collider itself. |
| ClosestPoint | Returns a point on the perimeter of this Collider that is closest to the specified position. |
| CreateMesh | Creates a planar Mesh that is identical to the area defined by the Collider2D geometry. |
| Distance | Calculates the minimum separation of this collider against another collider. |
| GetContacts | Retrieves all contact points for this Collider. |
| GetShapeHash | Generates a simple hash value based upon the geometry of the Collider2D. |
| GetShapes | Gets all the PhysicsShape2D used by the Collider2D. |
| IsTouching | Check whether this collider is touching the collider or not. |
| IsTouchingLayers | Checks whether this collider is touching any colliders on the specified layerMask or not. |
| OverlapCollider | Get a list of all colliders that overlap this collider. |
| OverlapPoint | Check if a collider overlaps a point in space. |
| Raycast | Casts a ray into the Scene that starts at the Collider position and ignores the Collider itself. |
| BroadcastMessage | Calls the method named methodName on every MonoBehaviour in this game object or any of its children. |
| CompareTag | Checks the GameObject's tag against the defined tag. |
| GetComponent | Gets a reference to a component of type T on the same GameObject as the component specified. |
| GetComponentInChildren | Gets a reference to a component of type T on the same GameObject as the component specified, or any child of the GameObject. |
| GetComponentInParent | Gets a reference to a component of type T on the same GameObject as the component specified, or any parent of the GameObject. |
| GetComponents | Gets references to all components of type T on the same GameObject as the component specified. |
| GetComponentsInChildren | Gets references to all components of type T on the same GameObject as the component specified, and any child of the GameObject. |
| GetComponentsInParent | Gets references to all components of type T on the same GameObject as the component specified, and any parent of the GameObject. |
| SendMessage | Calls the method named methodName on every MonoBehaviour in this game object. |
| SendMessageUpwards | Calls the method named methodName on every MonoBehaviour in this game object and on every ancestor of the behaviour. |
| TryGetComponent | Gets the component of the specified type, if it exists. |
| GetInstanceID | Gets the instance ID of the object. |
| ToString | Returns the name of the object. |
| Method | Description |
|---|---|
| Destroy | Removes a GameObject, component or asset. |
| DestroyImmediate | Destroys the object obj immediately. You are strongly recommended to use Destroy instead. |
| DontDestroyOnLoad | Do not destroy the target Object when loading a new Scene. |
| FindAnyObjectByType | Retrieves any active loaded object of Type type. |
| FindFirstObjectByType | Retrieves the first active loaded object of Type type. |
| FindObjectOfType | Returns the first active loaded object of Type type. |
| FindObjectsByType | Retrieves a list of all loaded objects of Type type. |
| FindObjectsOfType | Gets a list of all loaded objects of Type type. |
| Instantiate | Clones the object original and returns the clone. |
| Operator | Description |
|---|---|
| bool | Does the object exist? |
| operator != | Compares if two objects refer to a different object. |
| operator == | Compares two object references to see if they refer to the same object. |
| Message | Description |
|---|---|
| OnCollisionEnter2D | Sent when an incoming collider makes contact with this object's collider (2D physics only). |
| OnCollisionExit2D | Sent when a collider on another object stops touching this object's collider (2D physics only). |
| OnCollisionStay2D | Sent each frame where a collider on another object is touching this object's collider (2D physics only). |
| OnTriggerEnter2D | Sent when another object enters a trigger collider attached to this object (2D physics only). |
| OnTriggerExit2D | Sent when another object leaves a trigger collider attached to this object (2D physics only). |
| OnTriggerStay2D | Sent each frame where another object is within a trigger collider attached to this object (2D physics only). |