DeltaTime

Tutorial

Beginner

+0XP

5 mins

158

Unity Technologies

DeltaTime

什么是 Delta Time?如何在游戏中将其用于对值进行平滑和解释?

本教程包含在“初级编程”项目中。

上一教程:GetComponent

下一教程:数据类型

Languages available:

1. DeltaTime

UsingDeltaTimes

using UnityEngine;
using System.Collections;

public class UsingDeltaTime : MonoBehaviour
{
    public float speed = 8f; 
    public float countdown = 3.0f;

    
    void Update ()
    {
        countdown -= Time.deltaTime;
        if(countdown <= 0.0f)
            light.enabled = true;
        
         if(Input.GetKey(KeyCode.RightArrow))
            transform.position += new Vector3(speed * Time.deltaTime, 0.0f, 0.0f);
    }   
}

Complete this Tutorial