Time.deltaTime 增量时间
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class test01 : MonoBehaviour
{
public GameObject cube;
// Start is called before the first frame update
void Start()
{
cube = GameObject.Find("Cube");
}
// Update is called once per frame
void Update()
{
Debug.Log(Time.deltaTime);//每一帧的时间,不固定
//cube.transform.Translate(Vector3.right);//以帧计算
cube.transform.Translate(Vector3.right * Time.deltaTime);//以秒计算
}
}
运行结果