(サンプルコード)
*Questコントローラの特定ボタンを押したらVR空間で弾が発射される。
using UnityEngine;
public class ShotBeam : MonoBehaviour
{
private InputSystem_Actions isa;
public GameObject beamPrefab;
public AudioClip sound;
public GameObject anchor;
void Start()
{
isa = new InputSystem_Actions();
isa.Enable();
}
void Update()
{
if(isa.Player.Attack.triggered)
{
GameObject beam = Instantiate(beamPrefab, anchor.transform.position, Quaternion.identity);
Rigidbody beamRb = beam.GetComponent();
beamRb.AddForce(anchor.transform.forward * 1000);
AudioSource.PlayClipAtPoint(sound, transform.position);
Destroy(beam, 3.0f);
}
}
}
(右コントローラのAボタン)
(右コントローラのBボタン)
(右コントロラーのトリガーボタン)
(右コントローラのグリップボタン)