A set of parameters for filtering contact results. Define the angle by referring to their position in world space, where 0 degrees is parallel to the positive x-axis, 90 degrees is parallel to the positive y-axis, 180 degrees is parallel to the negative x-axis, and 270 degrees is parallel to the negative y-axis.
使用接触筛选器可准确控制返回的接触结果。这样无需在稍后筛选结果,因此更加快速和方便。
如果要使用的函数需要 ContactFilter2D,但不想执行任何过滤,请使用 ContactFilter2D.NoFilter。
有关将 ContactFilter2D 与投射结合使用的更多信息,请参阅:Physics2D.CircleCast、Physics2D.BoxCast、Physics2D.CapsuleCast、Physics2D.Linecast、Physics2D.Raycast、Collider2D.Raycast、Collider2D.Cast 和 Rigidbody2D.Cast。
有关将 ContactFilter2D 与重叠区域结合使用的更多信息,请参阅:Physics2D.OverlapPoint、Physics2D.OverlapCircle、Physics2D.OverlapBox、Physics2D.OverlapArea、Physics2D.OverlapCapsule、Physics2D.OverlapCollider、Rigidbody2D.OverlapCollider 和 Collider2D.OverlapCollider。
有关将 ContactFilter2D 与接触结合使用的更多信息,请参阅:Physics2D.GetContacts、Collider2D.GetContacts、Rigidbody2D.GetContacts、Physics2D.IsTouching、Rigidbody2D.IsTouching 和 Collider2D.IsTouching。
isFiltering | 鉴于接触筛选器的当前状态,确定其是否将筛选所有结果。 |
layerMask | 设置接触筛选器,使其筛选的结果仅包含层遮罩定义的层上的 Collider2D。 |
maxDepth | 设置接触筛选器,使其筛选的结果仅包含 Z 坐标(深度)小于该值的 Collider2D。 |
maxNormalAngle | 设置接触筛选器,使其筛选的结果仅包含碰撞法线角度小于该角度的接触。 |
minDepth | 设置接触筛选器,使其筛选的结果仅包含 Z 坐标(深度)大于该值的 Collider2D。 |
minNormalAngle | 设置接触筛选器,使其筛选的结果仅包含碰撞法线角度大于该角度的接触。 |
useDepth | 将接触筛选器设置为使用 minDepth 和 maxDepth 按深度筛选结果。 |
useLayerMask | 将接触筛选器设置为按层遮罩筛选结果。 |
useNormalAngle | 将接触筛选器设置为使用 minNormalAngle 和 maxNormalAngle 按碰撞的法线角度筛选结果。 |
useOutsideDepth | 将接触筛选器设置为在 minDepth 和 maxDepth 范围内或在此范围外进行筛选。 |
useOutsideNormalAngle | 将接触筛选器设置为在 minNormalAngle 和 maxNormalAngle 范围内或在此范围外进行筛选。 |
useTriggers | 进行设置,以便根据触发碰撞体的涉及情况筛选接触结果。 |
ClearDepth | 通过将 useDepth 设置为 false,关闭深度。minDepth 和 maxDepth 的关联值未更改。 |
ClearLayerMask | 通过将 useLayerMask 设置为 false,关闭层遮罩。layerMask 的关联值未更改。 |
ClearNormalAngle | 通过将 useNormalAngle 设置为 false,关闭法线角度筛选。minNormalAngle 和 maxNormalAngle 的关联值未更改。 |
IsFilteringDepth | 检查 obj 的 Transform 是否在要筛选的深度范围内。 |
IsFilteringLayerMask | 检查 obj 的 GameObject.layer 是否包含在要筛选的 layerMask 内。 |
IsFilteringNormalAngle | 检查 normal 的角度是否在要筛选的法线角度范围内。 |
IsFilteringTrigger | 检查该 collider 是否是触发器,以及是否应按照要筛选的 useTriggers 进行筛选。 |
NoFilter | 将接触筛选器设置为不筛选任何 ContactPoint2D。 |
SetDepth | 设置 minDepth 和 maxDepth 筛选器属性,然后通过将 useDepth 设置为 true,打开深度筛选。 |
SetLayerMask | 使用提供的 layerMask 参数设置 layerMask 筛选器属性,此外通过将 useLayerMask 设置为 true,启用层遮罩筛选。 |
SetNormalAngle | 设置 minNormalAngle 和 maxNormalAngle 筛选器属性,然后通过将 useNormalAngle 设置为 true,打开法线角度筛选。 |
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.