音の設定はココを参考にした。
一部だけ抜粋して使ってたら、音なんねー!とか3D音響なんねー!とかになった。
ちゃんと全部使ったらできました。
面倒くさがらずにちゃんと読まないとダメね(´・ω・`)
コントローラーの入力はココ
とか
とか。
でも二つ目のサンプルは動かなかったわぁ。
というか入力受け付けてるのかすら判断できない。
OVRCameraRig > TrackingSpace > RightHandAnchor > RightControllerAnchorにスクリプトアタッチしてたけど、
OVRCameraRigのみ配置してたのを、OVRPlayerControllerに変更してそっちにアタッチしたら入力は確認できた。上のサンプルは試してないけどねw
ソースを引用して切り貼りした結果、
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlaySound2 : MonoBehaviour
{
// Start is called before the first frame update
[SerializeField] AudioClip[] clips;
[SerializeField] bool randomizePitch = true;
[SerializeField] float pitchRange = 0.1f;
protected AudioSource source;
private void Awake()
{
// アタッチしたオーディオソースのうち1番目を使用する
source = GetComponents<AudioSource>()[0];
}
void Update()
{
if (randomizePitch)
source.pitch = 1.0f + Random.Range(-pitchRange, pitchRange);
if (Input.GetMouseButtonUp(0))
{
// source.PlayOneShot(clips[0]);
}
if (OVRInput.GetDown(OVRInput.Button.PrimaryThumbstickUp, OVRInput.Controller.LTouch))
{
source.PlayOneShot(clips[0]);
}
if (OVRInput.GetDown(OVRInput.Button.PrimaryThumbstickRight, OVRInput.Controller.LTouch))
{
source.PlayOneShot(clips[1]);
}
if (OVRInput.GetDown(OVRInput.Button.PrimaryThumbstickDown, OVRInput.Controller.LTouch))
{
source.PlayOneShot(clips[2]);
}
if (OVRInput.GetDown(OVRInput.Button.PrimaryThumbstickLeft, OVRInput.Controller.LTouch))
{
source.PlayOneShot(clips[3]);
}
}
}
こんな感じになった。使ってないのとかそのままだけど、とりあえず動いてるからこれでいいやw