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.

Returns the same value if called multiple times in a single frame. When called from inside MonoBehaviour's FixedUpdate, returns fixedTime property. Try to avoid regular (frame) use of Time.time. It is more intended to supply the time the game has been running, and not time per frame.

Note: Time.time starts once all Awake functions have finished. The time value will be undefined during Awake functions.

using UnityEngine;
using System.Collections;

// Instantiates a projectile off every 0.5 seconds, // if the Fire1 button (default is ctrl) is pressed.

public class ExampleScript : 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; GameObject clone = Instantiate(projectile, transform.position, transform.rotation) as GameObject; } } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961