Version: 5.3 (switch to 5.4b)
IdiomaEnglish
  • C#
  • JS

Idioma de script

Selecciona tu lenguaje de programación favorito. Todos los fragmentos de código serán mostrados en este lenguaje.

Time.deltaTime

Cambiar al Manual
public static float deltaTime;

Descripción

El tiempo en segundos que tardó en completarse el último frame (Read Only).

Usa esta función para hacer que tu juego funcione independientemente del frame rate.

If you add or subtract to a value every frame chances are you should multiply with Time.deltaTime. Cuando multiplicas por Time.deltaTime lo que haces es expresar: quiero mover este objeto 10 metros por segundo en vez de 10 metros por frame.

When called from inside MonoBehaviour's FixedUpdate, returns the fixed framerate delta time.

Note that you should not rely on Time.deltaTime from inside OnGUI since OnGUI can be called multiple times per frame and deltaTime would hold the same value each call, until next frame where it would be updated again.

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { void Update() { float translation = Time.deltaTime * 10; transform.Translate(0, 0, translation); } }