The time in scenes it took to complete the last frame。這是使用此函數的時候給出的提示
一般我們會在設置速度的時候看到這個函數。先寫出我對Time.deltaTime的理解。即每秒物體移動的速度。注意,不是每幀物體移動的速度(如果是每幀的話,那跑的太快了。。。)。
如果你加上或者減去一個值,那你很可能應該乘以Time.deltaTime。
請注意,在OnGUI中你不應該依賴Time.deltaTime,因為OnGUI有可能在一幀中被多次調用並且每次deltatime的值都是相同的,直到下一幀刷新。
當從MonoBehavior的Fixedupdate中調用的時候,返回的幀速率增量時間。
以下是unity官方給出的示例代碼:
1 using UnityEngine; 2 using System.Collections; 3 4 public class ExampleClass : MonoBehaviour { 5 void Update() { 6 float translation = Time.deltaTime * 10; 7 transform.Translate(0, 0, translation); 8 } 9 }