所有碰撞器的基类。
其他资源:BoxCollider、SphereCollider、CapsuleCollider、MeshCollider、PhysicsMaterial、Rigidbody。
如果在游戏玩法过程中需要移动具有碰撞器的对象,则还应将 Rigidbody 组件添加到该对象。如果不想让对象与其他对象发生物理交互,则可以将 Rigidbody 设置为运动的。
attachedArticulationBody | 碰撞器所附加的关节体。 |
attachedRigidbody | 碰撞器所附加的刚体。 |
bounds | 碰撞器的世界空间边界卷(只读)。 |
contactOffset | 此碰撞器的接触偏移值。 |
enabled | 已启用的碰撞器将与其他碰撞器发生碰撞,而已启用的碰撞器不会发生碰撞。 |
excludeLayers | 该碰撞器在决定碰撞器是否可以与另一个碰撞器接触时应排除的其他图层。 |
GeometryHolder | 包含碰撞器的几何形状及其类型的结构。(只读) |
hasModifiableContacts | 指定此碰撞器的接触点是否可修改。 |
includeLayers | 该碰撞器在决定碰撞器是否可以与另一个碰撞器接触时应包含的其他图层。 |
isTrigger | 指定此碰撞器是否配置为触发器。 |
layerOverridePriority | 当对碰撞器是否可以与另一个碰撞器接触做出矛盾的决定时,分配给此碰撞器的决策优先级。 |
material | 碰撞器所使用的材料。 |
providesContacts | 此碰撞器是否可为 Physics.ContactEvent 生成联系人。 |
sharedMaterial | 此碰撞器的共享物理材质。 |
ClosestPoint | 返回碰撞器上最靠近给定位置的一个点。 |
ClosestPointOnBounds | 到附着碰撞器包围盒的最靠近一点。 |
GetGeometry | 返回所需类型碰撞器的几何形状。 |
Raycast | 投射一条忽略此碰撞器之外的所有碰撞器的射线。 |
OnCollisionEnter | 当此碰撞器/刚体开始接触另一个刚体/碰撞器时调用 OnCollisionEnter。 |
OnCollisionExit | 当此碰撞器/刚体停止接触另一个刚体/碰撞器时调用 OnCollisionExit。 |
OnCollisionStay | 对于每个接触另一个碰撞器或刚体的碰撞器或刚体,每帧调用 OnCollisionStay 一次。 |
OnTriggerEnter | 当 GameObject 与另一个 GameObject 碰撞时,Unity 调用 OnTriggerEnter。 |
OnTriggerExit | 当碰撞器 other 停止接触触发器时调用 OnTriggerEnter。 |
OnTriggerStay | 对于每个接触触发器的碰撞器 other,OnTriggerStay 几乎每帧调用一次。此函数采用物理计时器,因此不一定每帧运行。 |
gameObject | 此组件附着的游戏对象。组件始终附着到一个游戏对象。 |
tag | 此游戏对象的标记。 |
transform | 此 GameObject 上附着的 Transform。 |
hideFlags | 该对象是否隐藏、与场景一起保存或可以由用户修改? |
name | 对象名称。 |
BroadcastMessage | 对此游戏对象或其任何子对象的每个 MonoBehaviour 调用方法名称 methodName。 |
CompareTag | 检查 GameObject 的标记与定义的标记。 |
GetComponent | 获取指定的组件上 GameObject 中类型的 T 的引用。 |
GetComponentInChildren | 获取指定的组件上 GameObject 或 GameObject 的任何子对象中类型的 T 的引用。 |
GetComponentIndex | 获取其父 GameObject 上组件的索引。 |
GetComponentInParent | 获取指定的组件或 GameObject 的任何父对象上 GameObject 中类型的 T 的引用。 |
GetComponents | 获取指定的组件上 GameObject 中所有类型为 T 的组件的引用。 |
GetComponentsInChildren | 获取指定的组件或 GameObject 的任何子对象中所有类型为 T 的组件的引用。 |
GetComponentsInParent | 获取指定的组件或 GameObject 的任何父对象中所有类型为 T 的组件的引用。 |
SendMessage | 对此游戏对象的每个 MonoBehaviour 调用方法名称 methodName。 |
SendMessageUpwards | 在该游戏对象和行为的每个祖先上调用该方法 methodName 命名的方法。 |
TryGetComponent | 获取指定类型的组件(如果存在)。 |
GetInstanceID | 获取对象的实例 ID。 |
ToString | 返回对象的名称。 |
Destroy | 移除一个 GameObject、组件或 asset。 |
DestroyImmediate | 立即销毁对象 obj。强烈建议你使用 Destroy。 |
DontDestroyOnLoad | 加载新场景时,不要销毁目标对象。 |
FindAnyObjectByType | 检索任何已加载的 Type 类型活动的对象。 |
FindFirstObjectByType | 检索第一个已加载的 Type 类型活动的对象。 |
FindObjectsByType | 检索一个 Type 类型所有已加载对象列表。 |
Instantiate | 克隆对象 original 并返回克隆。 |
InstantiateAsync | 捕获原始对象(必须与某个 GameObject 相关)的快照,然后返回 AsyncInstantiateOperation。 |
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.