このフレームの開始する時間(Read Only)。ゲーム開始からの時間(秒)です。
ひとつのフレームで複数回呼び出す場合は同じ値を返します。 MonoBehaviour の FixedUpdate 内部から呼び出されたとき、 fixedTime プロパティーを返します。
// Instantiates a projectile off every 0.5 seconds, // if the Fire1 button (default is ctrl) is pressed.
var projectile : GameObject; var fireRate = 0.5; private var nextFire = 0.0;
function Update () { if (Input.GetButton ("Fire1") && Time.time > nextFire) { nextFire = Time.time + fireRate; var clone = Instantiate (projectile, transform.position, transform.rotation); } }
using UnityEngine; using System.Collections;
public class ExampleClass : 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; } } }
注意: time はすべての Awake 関数が呼び出された後に初期化されます。 time の値は Awake 関数中は定義されていません。