Version: 5.3 (switch to 5.4b)
言語English
  • C#
  • JS

スクリプト言語

好きな言語を選択してください。選択した言語でスクリプトコードが表示されます。

Input.GetButton

マニュアルに切り替える
public static bool GetButton(string buttonName);

パラメーター

説明

buttonName で識別される仮想ボタンを押している間 true を返します

オート射撃 - これはボタンを押している限り true を返します。

武器を撃つようなアクションのトリガーイベントを実装するときのみに使用します。 連続的な動きを制御するための入力は GetAxis を使用してください。

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; } } }