Unity3D圣典3.3版本-中文版
文集大纲加载中……
本文档使用 MrDoc 发布
-
+
首页
Time.deltaTime 增量时间
# [Time](Time.html).deltaTime 增量时间 static var *deltaTime* : float *Description* 描述 The time in seconds it took to complete the last frame (Read Only). 以秒计算,完成最后一帧的时间(只读)。 Use this function to make your game frame rate independent. 使用这个函数使和你的游戏帧速率无关。 > 放在 Update()函数中的代码是以帧来执行的.如果我们需要物体的移动以秒来执行.我们需要将物体移动的值乘以 Time.deltaTime。 If you add or subtract to a value every frame chances are you should multiply with [Time.deltaTime](Time.deltaTime.html). When you multiply with [Time.deltaTime](Time.deltaTime.html) you essentially express: I want to move this object 10 meters per second instead of 10 meters per frame. 如果你加或减一个每帧改变的值,你应该与 [Time.deltaTime](Time.deltaTime.html) 相乘。当你乘以 [Time.deltaTime](Time.deltaTime.html) 实际表示:每秒移动物体 10 米,而不是每帧 10 米。 When called from inside MonoBehaviour's [FixedUpdate](../MonoBehaviour/MonoBehaviour.FixedUpdate.html), returns the fixed framerate delta time. 当从 [MonoBehaviour](../MonoBehaviour/MonoBehaviour.html) 的 [FixedUpdate](../MonoBehaviour/MonoBehaviour.FixedUpdate.html) 里调用时,返回固定帧速率增量时间([fixedDeltaTime](Time.fixedDeltaTime.html))。 Note that you should not rely on [Time.deltaTime](Time.deltaTime.html) from inside [OnGUI](../MonoBehaviour/MonoBehaviour.OnGUI.html) since OnGUI can be called multiple times per frame and deltaTime would hold the same value each call, until next frame where it would be updated again. 请注意从 [OnGUI](../MonoBehaviour/MonoBehaviour.OnGUI.html) 里你不应该依赖于 [Time.deltaTime](Time.deltaTime.html),因为 OnGUI 可以在每帧被多次调用并且每个调用 deltaTime 将持有相同的值,直到下一帧再次更新。 * [C#](#) * [JavaScript](#) ``` using UnityEngine; using System.Collections; public class example : MonoBehaviour { void Update() { float translation = Time.deltaTime * 10; transform.Translate(0, 0, translation); } } ``` ``` function Update () { // Move the object 10 meters per second! //每秒移动物体10米 var translation : float = Time.deltaTime * 10; transform.Translate (0, 0, translation); } ```
da
2022年5月23日 14:35
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
关于 MrDoc
觅思文档MrDoc
是
州的先生
开发并开源的在线文档系统,其适合作为个人和小型团队的云笔记、文档和知识库管理工具。
如果觅思文档给你或你的团队带来了帮助,欢迎对作者进行一些打赏捐助,这将有力支持作者持续投入精力更新和维护觅思文档,感谢你的捐助!
>>>捐助鸣谢列表
微信
支付宝
QQ
PayPal
Markdown文件
分享
链接
类型
密码
更新密码