お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。
Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.
Close/buttonName/ で識別される仮想ボタンを押している間trueを返します
オート射撃 - これはボタンを押している限りtrueを返します。 武器を撃つようなアクションのトリガーイベントを実装するときのみに使用します。 連続的な動きを制御するための入力は GetAxis を使用してください。
// Instantiates a projectile every 0.5 seconds, // if the Fire1 button (default is Ctrl) is pressed. var projectile : GameObject; var fireRate : float = 0.5; private var nextFire : float = 0.0; function Update () { if (Input.GetButton("Fire1") && Time.time > nextFire) { nextFire = Time.time + fireRate; 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; Instantiate(projectile, transform.position, transform.rotation) as GameObject; } } }
import UnityEngine import System.Collections public class ExampleClass(MonoBehaviour): public projectile as GameObject public fireRate as float = 0.5F private nextFire as float = 0.0F def Update() as void: if Input.GetButton('Fire1') and (Time.time > nextFire): nextFire = (Time.time + fireRate) (Instantiate(projectile, transform.position, transform.rotation) as GameObject)