unity中Time.deltaTime的详细使用
deltaTime–增量时间
官方解释如下:
此属性提供当前帧和上一帧之间的时间。使用Time.deltaTime以每秒单位的速度向该方向移动游戏对象。
乘以Time.deltaTime并添加到组件。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// Time.deltaTime example.
//
// Wait two seconds and display waited time.
// This is typically just beyond 2 seconds.
// Allow the speed of the time to be increased or decreased.
// It can range between 0.5 and 2.0. These changes only
// happen when the timer restarts.
public class ScriptExample : MonoBehaviour
{
private float waitTime = 2.0f;
private float timer = 0.0f;
private float visualTime = 0.0f;
private int width, height;
private float value = 10.0f;
private float scrollBar = 1.0f;
void Awake()
{
width = Screen.width;
height = Screen.height;
Time.timeScale = scrollBar;
}
void Update()
<