(サンプルコード)
・「Attack」はデフォルトでは「キーボードのエンターキー」に対応している。
using UnityEngine;
public class Fire : MonoBehaviour
{
private InputSystem_Actions isa;
public GameObject beamPrefab;
private int count;
public AudioClip sound;
private void Start()
{
isa = new InputSystem_Actions();
isa.Enable();
}
void FixedUpdate()
{
if (isa.Player.Attack.IsPressed()) // エンターキーを押している時(ポイント)
{
count += 1;
if (count % 5 == 0)
{
Instantiate(beamPrefab, transform.position, Quaternion.identity);
AudioSource.PlayClipAtPoint(sound, transform.position);
}
}
}
}
・生成されたビームは、自動飛行する。
using UnityEngine;
public class NormalBeam : MonoBehaviour
{
void Update()
{
transform.Translate(Vector3.forward * Time.deltaTime * 50);
}
}