The Composite Collider 2D component is a Collider that interacts with the 2D physics system. Unlike most colliders, it does not define an inherent shape. Instead, it merges the shapes of any Box Collider 2D or Polygon Collider 2D that you set it up to use. The Composite Collider 2D uses the vertices (geometry) from any of these Colliders, and merges them together into new geometry controlled by the Composite Collider 2D itself.
Both the Box Collider 2D and Polygon Collider 2D components have a Used By Composite checkbox. Select this checkbox to attach them to the Composite Collider 2D. These Colliders must also be attached to the same Rigidbody 2D as the Composite Collider 2D. When you enable Used by Composite, other properties disappear from that component, as they are now controlled by the attached Composite Collider 2D.
Refer to the CompositeCollider2D API documentation for more information about scripting with the Composite Collider 2D.
属性 | 功能 |
---|---|
Density | Change the density 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 centre of mass calculations. Note that this option is only available if you have enabled Use Auto Mass in the associated Rigidbody 2D component. |
Material | 一种 2D 物理材质,可用于确定碰撞的属性(例如摩擦和弹性)。 |
Is Trigger | 如果希望 2D 复合碰撞体作为触发器运行,请选中此框(请参阅关于碰撞体的概述文档以了解有关触发器的更多信息)。 |
Used by Effector | 如果希望 2D 复合碰撞体由附加的 2D 效应器组件使用,请选中此框。 |
Offset | 设置 2D 碰撞体几何形状的局部偏移。 |
Geometry Type | When merging Colliders, the vertices from the selected Colliders are composed into one of two different geometry types. Use this drop-down to set the geometry type to either Outlines or Polygons. |
Outlines | 生成具有空心轮廓的 2D 碰撞体,与 2D 边界碰撞体 (Edge Collider 2D) 生成的结果一样。 |
Polygons | 生成具有实心多边形的 2D 碰撞体,与 2D 多边形碰撞体 (Polygon Collider 2D) 生成的结果一样。 |
Generation Type | 该方法用于控制在更改 2D 复合碰撞体时或者更改其任何成员碰撞体时何时生成几何体。 |
Synchronous | 对 2D 复合碰撞体或其使用的任何碰撞体进行更改时,Unity 立即生成新几何体。 |
Manual | New geometry generation happens only when you request it. To request generation, either call the CompositeCollider2D.GenerateGeometry script API, or click the Regenerate Geometry button that appears under the selection. |
Vertex Distance | 设置从复合碰撞体收集的任何顶点允许的最小间距值。比此限值更近的任何顶点都将被删除。此设置可用于控制顶点合成的有效分辨率。 |
Edge Radius | Controls a radius around edges, so that vertices are circular. This results in a larger Collider 2D with rounded convex corners. The default value for this setting is 0 (no radius). This only works when the Geometry Type is set to Outlines. |
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.