Have a BIG problem I whould say.
I want to play a sound when the MainCamera of the HTC Vive [CameraRig] enter my trigger that is a CUBE.
So this is how I have set it up.
I have a CUBE that is set *is trigger. The [CameraRig] has a AudioListener and the CUBE has a AudioSource and my Script is attached to the CUBE.
The MainCamera of the [CameraRig] is Camera (head) and it has a Rigidbody attach that is set to is kinematic.
So that what the setup looks like and here is the script:
using UnityEngine;
using System.Collections;
public class PlaySound : MonoBehaviour {
public AudioClip soundToPlay;
public float volume;
AudioSource audio;
public bool played = false;
// Use this for initialization
void Start () {
audio = GetComponent<AudioSource>();
}
void OnTriggerEnter() {
if (!played) {
audio.PlayOneShot (soundToPlay, volume);
played = true;
}
}
// Update is called once per frame
void Update () {
}
}
When the Camera (head) collide with the CUBE nothing happen.
Why is this?