Version: 2021.3
2D 复合碰撞体 (Composite Collider 2D)
2D 物理材质

Custom Collider 2D

The Custom Collider 2D is a Collider that interacts with the 2D physics system. Unlike other Colliders, you do not configure the Collider in-Editor, instead you configure the Collider by assigning PhysicsShape2D geometry to it via the PhysicsShapeGroup2D API. You can further define the Collider by adding, removing and modifying the PhysicsShape2D shapes. Refer to the PhysicsShape2D API documentation for more information. This also means that a Custom Collider 2D can contain an unlimited number of low-level PhysicsShape2D and represent any type of shape, or emulate other types of Collider 2D.

When assigning PhysicsShape2D to the Custom Collider 2D, you can do so either during Edit mode or Play mode. When modifying the Custom Collider 2D in Edit mode, Unity saves all assigned PhysicsShape2D and associated vertices in the Unity Scene, and the CustomCollider2D retains its configuration when the Scene is loaded. This makes it possible to use Edit mode authoring scripts to create custom geometry.

When modifying the Custom Collider 2D during Play mode, the Collider will not retain any changes made to assigned PhysicsShape2D and their associated vertices, and all changes will be lost when exiting Play mode.

Custom Collider 2D properties
Custom Collider 2D properties
属性 功能
Density Change the Density value to change the mass calculations of the GameObject’s associated Rigidbody 2D. If you set the value to 0, its associated Rigidbody 2D ignores the Collider 2D for all mass calculations, including center of mass calculations. Note: This property is only available when the Rigidbody 2D component attached to the GameObject has Use Auto Mass enabled.
Material 一种 2D 物理材质,可用于确定碰撞的属性(例如摩擦和弹性)。
Is Trigger Enable this property if you want the Custom Collider 2D to behave as a trigger (refer to Colliders Overview for more information on using triggers).
Used By Effector Enable this property if you want the Custom Collider 2D to be used by an attached Effector 2D component.
Offset Set the local offset values of the Collider 2D geometry.
Custom Shape Count (Read Only) Indicates how many PhysicsShape2D the Collider is using.
Custom Vertex Count (Read Only) Indicates how many vertices all PhysicsShape2D in the Collider are using.
2D 复合碰撞体 (Composite Collider 2D)
2D 物理材质
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961