/// <summary> /// Plays audio clips depending on if nodes are seen or not. /// </summary> private void Update() { directionToPlayerCamera = transform.position - nextNode.transform.position; float dotProduct = Vector3.Dot(directionToPlayerCamera.normalized, transform.forward); AudioSource source = nextNode.GetComponentInChildren <AudioSource>(); if (SeeingNode) { if (!source.clip.Equals(seeingClip) && !playing) { StartCoroutine(ChangeClip(seeingClip)); } if (dotProduct > -visionArc) { if (!source.clip.Equals(notSeeingClip) && !playing) { StartCoroutine(ChangeClip(notSeeingClip)); } SeeingNode = false; //First number is lenght, second is strength from 0 to 255 then it repeats so every value has to be a pair. long[] timings = { 500, 200, 500, 100, 500, 200 }; Vibration.CreateWaveform(timings, -1); } } else if (dotProduct < -visionArc) { SeeingNode = true; } AudioListener.volume = listenerVolume * volumeSlider.value; }