The Polygon Collider 2D component is a Collider that interacts with the 2D physics system. The Collider’s shape is defined by a freeform edge made of line segments, that you can adjust to fit the shape of the Sprite or any other shape. Note that this Collider’s edge must completely enclose an area to function.
属性 | 功能 |
---|---|
Material | 一种物理材质,可用于确定碰撞的属性(例如摩擦和弹性)。 |
Is Trigger | 如果希望此碰撞体作为触发器运行,请勾选此框。 |
Used by Effector | 附加的效应器是否使用该碰撞体。 |
Used by Composite | Tick this checkbox if you want this Collider to be used by an attached Composite Collider 2D. When you enable Used by Composite, other properties disappear from the Polygon Collider 2D component, because they are now controlled by the attached Composite Collider 2D. The properties that disappear from the Box Collider 2D are Material, Is Trigger, Used By Effector, and Edge Radius. |
Used by Collider | 如果希望 2D 盒型碰撞体由附加的 2D 复合碰撞体组件使用,请选中此框。 |
Auto Tiling | Tick this checkbox if you have set the Draw Mode of the Sprite Renderer component to Tiled. This enables automatic updates to the shape of the Collider 2D, meaning that the shape is automatically readjusted when the Sprite’s dimensions change. If you don’t enable Auto Tiling, the Collider 2D stays the same shape and size, even when the Sprite’s dimensions change. |
Offset | 碰撞体几何形状的局部偏移。 |
Points | 有关生成碰撞体的复杂性的不可编辑信息。 |
允许手动编辑该碰撞体,但让 Unity 自动确定形状通常更方便。若要进行此操作,可将精灵资源从 Project 视图拖到 Inspector 中的 2D 多边形碰撞体组件。
You can edit the polygon’s shape by pressing the Edit Collider button in the Inspector. You can exit Collider edit mode by pressing the Edit Collider button again. While in edit mode, you can move an existing vertex by dragging when the mouse is over that vertex. If you shift-drag while the mouse is over an edge, a new vertex will be created at the mouse location. You can remove a vertex by holding down the ctrl/cmd key while clicking on it.
Note that you can hide the outline of the 2D move Gizmo while editing the Collider by selecting the fold-out arrow on the Sprite Renderer component in the Inspector to collapse it.