Unity3D圣典3.3版本-中文版
文集大纲加载中……
本文档使用 MrDoc 发布
-
+
首页
Collider.OnTriggerStay 逗留触发器
# [Collider](Collider.html).OnTriggerStay 逗留触发器 function *OnTriggerStay* (*other* : Collider) : void *Description* 描述 OnTriggerStay is called *almost* all the frames for every [Collider](Collider.html) **other** that is touching the trigger. 每个碰撞器 other 触动触发器,几乎在所有的帧 OnTriggerStay 被调用。通俗的说, 每个碰撞器从进入触发器那一刻到退出触发器之前,几乎每帧都会调用 OnTriggerStay。 This message is sent to the trigger collider and the rigidbody (or the collider if there is no rigidbody) that touches the trigger. Note that trigger events are only sent if one of the colliders also has a rigidbody attached. 这个消息是发送给触动触发器的碰撞器和刚体(或如果没有刚体的碰撞器)。注意假如一个碰撞物体同时带有一个刚体属性 那么只发送这个触发事件。 **Note:** OnTriggerStay function is on the physics timer so it wont necessary run every frame. 注意:OnTriggerStay 函数是基于物理计时器,因此它未必每帧都运行。 也就是说 OnTriggerStay 是在每一个 Time.fixedDeltaTime 的时间节点上运行,不是 Time.deltaTime 的时间节点上运行 * [C#](#) * [JavaScript](#) ``` using UnityEngine; using System.Collections; public class example : MonoBehaviour { void OnTriggerStay(Collider other) { if (other.attachedRigidbody) other.attachedRigidbody.AddForce(Vector3.up * 10); } } ``` ``` // Applies an upwards force to all rigidbodies that enter the trigger. //进入触发器给所有的刚体应用向上的力 function OnTriggerStay (other : Collider) { if (other.attachedRigidbody) { other.attachedRigidbody.AddForce(Vector3.up * 10); } } ```
da
2022年5月17日 17:52
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
关于 MrDoc
觅思文档MrDoc
是
州的先生
开发并开源的在线文档系统,其适合作为个人和小型团队的云笔记、文档和知识库管理工具。
如果觅思文档给你或你的团队带来了帮助,欢迎对作者进行一些打赏捐助,这将有力支持作者持续投入精力更新和维护觅思文档,感谢你的捐助!
>>>捐助鸣谢列表
微信
支付宝
QQ
PayPal
Markdown文件
分享
链接
类型
密码
更新密码