返回介绍

Collider 碰撞器

发布于 2019-12-18 15:37:32 字数 4652 浏览 1408 评论 0 收藏 0

Namespace: UnityEngine
Inherits from: Component

Description 描述

A base class of all colliders.

所有碰撞器的基类。

See Also: BoxCollider, SphereCollider, CapsuleCollider, MeshCollider, PhysicMaterial, Rigidbody.

If the object with the Collider needs to be moved during gameplay then you should also attach a Rigidbody component to the object. The Rigidbody can be set to be kinematic if you don't want the object to have physical interaction with other objects.

如果一个对象带有碰撞器,需要在游戏中移动,那么你应该添加个Rigidbody组件给它。如果你不想该对象与其他对象有交互,刚体可以设置为运动学刚体(kinematic)。

Variables 变量

attachedRigidbodyThe rigidbody the collider is attached to.
碰撞器附加的刚体。
boundsThe world space bounding volume of the collider.
碰撞器框的体积大小。
contactOffsetContact offset value of this collider.
该碰撞器的触点偏移值。
enabledEnabled Colliders will collide with other colliders, disabled Colliders won't.
启用碰撞器将会碰撞其他碰撞器,禁用碰撞器就不会碰撞其他碰撞器。
isTriggerIs the collider a trigger?
碰撞器是一个触发器?
materialThe material used by the collider.
用于碰撞器的材质。
sharedMaterialThe shared physic material of this collider.
该碰撞器的共享的物理材质。

Public Functions 共有函数

ClosestPointOnBoundsThe closest point to the bounding box of the attached collider.
到碰撞器的框最近的点。
RaycastCasts a Ray that ignores all Colliders except this one.
投射一条射线(Ray),它忽略所有碰撞器,除了这个。

Messages 消息

OnCollisionEnterOnCollisionEnter is called when this collider/rigidbody has begun touching another rigidbody/collider.
当该collider/rigidbody开始碰到另一个rigidbody/collider时OnCollisionEnter被调用。
OnCollisionExitOnCollisionExit is called when this collider/rigidbody has stopped touching another rigidbody/collider.
当 collider/rigidbody停止碰撞另一个 rigidbody/collider时,OnCollisionExit被调用。
OnCollisionStayOnCollisionStay is called once per frame for every collider/rigidbody that is touching rigidbody/collider.
每当该collider/rigidbody碰到其他rigidbody/collider,将在每帧调用OnCollisionStay。
OnTriggerEnterOnTriggerEnter is called when the Collider other enters the trigger.
当碰撞器进入触发器时OnTriggerEnter被调用。
OnTriggerExitOnTriggerExit is called when the Collider other has stopped touching the trigger.
当该碰撞器停止接触触发器时,OnTriggerExit被调用。也就是说,当碰撞器离开触发器时,调用OnTriggerExit。
OnTriggerStayOnTriggerStay is called almost all the frames for every Collider other that is touching the trigger.
每当碰撞器从进入触发器,几乎每帧调用OnTriggerStay。

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文