Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


CompositeCollider2D

A Collider that can merge other Colliders together.
Read time 11 minutesLast updated 4 days ago

Definition

[RequireComponent(typeof(Rigidbody2D))]public sealed class CompositeCollider2D : Collider2D

Remarks

A CompositeCollider2D merges other Colliders together when their Collider2D.compositeOperation is anything other than Collider2D.CompositeOperation.None, that is, whenever a composite operation is selected.
When a Composite Collider uses a Collider, the Editor will ignore and not show the Collider2D.sharedMaterial, Collider2D.isTrigger & Collider2D.compositeOperation properties. The same properties on the CompositeCollider2D will be used instead. You should set these properties on the Composite Collider to merge all Colliders into the Composite Collider.
NOTE: This Collider2D cannot be disabled/enabled with the Behaviour.enabled property. Any changes to that property will be ignored.

Properties

Property

Description

edgeRadiusControls the radius of all edges created by the Collider.
generationTypeSpecifies when to generate the Composite Collider geometry.
geometryTypeSpecifies the type of geometry the Composite Collider should generate.
offsetDistanceVertices are offset by this distance when compositing multiple physic shapes. Any vertices between shapes within this distance are combined.
pathCountThe number of paths in the Collider.
pointCountGets the total number of points in all the paths within the Collider.
useDelaunayMeshWhen the value is true, the Collider uses an additional Delaunay triangulation step to produce the Collider mesh. When the value is false, this additional step does not occur.
vertexDistanceControls the minimum distance allowed between generated vertices.

Methods

Method

Description

GenerateGeometryRegenerates the Composite Collider geometry.
GetCompositedCollidersWhen any Collider2D is using any composite operation other than Collider2D.CompositeOperation.None then it is used by this CompositeCollider2D.
GetPathGets a path from the Collider by its index.
GetPathPointCountGets the number of points in the specified path from the Collider by its index.

Enums

Enum

Description

CompositeCollider2D.GenerationTypeSpecifies when to generate the Composite Collider geometry.
CompositeCollider2D.GeometryTypeSpecifies the type of geometry the Composite Collider generates.

Inheritance

Inherited Members

Operators

Operator

Description

operator ==Compares two object references to see if they refer to the same object.
boolDetermines whether the object exists.
operator !=Compares if two objects refer to a different object.