一、Time 类
作用:保证对象匀速移动。Time.deltaTime
1.用来控制移动速度
2.解决 Update()方法由于帧率的影响导致每一帧移动时时间不同的情况。
在Translate()方法中使用
using System.Collections; using System.Collections.Generic; using UnityEngine; public class TimeDemo : MonoBehaviour { // Use this for initialization void Start () { } // Update is called once per frame void Update () { this.transform.Translate(Vector3.up * Time.deltaTime); } }
在Rorate()方法中使用
using System.Collections; using System.Collections.Generic; using UnityEngine; public class TimeDemo : MonoBehaviour { // Use this for initialization void Start () { } // Update is called once per frame void Update () { this.transform.Rotate(Vector3.down * Time.deltaTime); } }