public static float time ;

Descripción

El tiempo al comienzo de este frame (Lectura Solamente). Este es el tiempo en segundos desde el inicio del juego.

Time.time is the amount of time in seconds that the application has been running for. It is read-only.

The application receives the current Time.time at the beginning of each frame, with the value increasing per frame. A time call per frame receives the same value. When called from FixedUpdate it returns the Time.fixedTime property.

Regular (per frame) calls should be avoided: Time.time is intended to supply the length of time the application has been running for, and not the time per frame.

The value of Time.time is undefined during Awake messages and will start after all messages are finished. Time.time will not update if the Editor is paused. See Time.realtimeSinceStartup for a time value that is unaffected by pausing.

//If the Fire1 button is pressed, a projectile
//will be Instantiated every 0.5 seconds.

using UnityEngine; using System.Collections;

public class Example : MonoBehaviour { public GameObject projectile; public float fireRate = 0.5f; private float nextFire = 0.0f;

void Update() { if (Input.GetButton("Fire1") && Time.time > nextFire) { nextFire = Time.time + fireRate; Instantiate(projectile, transform.position, transform.rotation); } } }