原始碼的定義如下
public static float deltaTime;
含義為
The interval in seconds from the last frame to the current one (Read Only).
從最后一幀到當前幀的間隔(以秒為單位)(只讀),
假設一秒執行30幀,那么如果一個物體要在一秒內在x軸移動10個單位的距離
那么在Update函式里面呼叫時就需要使用
transform.Translate(10f*Time.deltaTime,0,0,Space.Self);
接著
When this is called from inside MonoBehaviour.FixedUpdate, it returns Time.fixedDeltaTime.
當從MonoBehaviour.FixedUpdate內部呼叫此方法時,它將回傳Time.fixedDeltaTime
FixedUpdate是具有物理系統的頻率,它被稱為每個固定幀率幀,也就是說它的每兩幀呼叫時間間隔是相等的,而且默認時間為0.02秒(每秒50次呼叫),這個0.02秒就是Time.fixedDeltaTime,可通過projectsettings設定

要注意的是
deltaTime inside MonoBehaviour.OnGUI is not reliable,
because Unity might call it multiple times per frame.
MonoBehaviour.OnGUI中的deltaTime不可靠,因為Unity可能每幀多次呼叫它
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/282711.html
標籤:其他
下一篇:煙花
