The first problem is when the audio clip plays. I just want it to play when a unit/units are selected. However its playing every time I release the left mouse button?
using UnityEngine;
using System.Collections;
public class Unit : MonoBehaviour
{
public Projector lightRing;
public AudioClip YesSir;
public bool selected = false;
void Start()
{
lightRing = GetComponentInChildren<Projector>();
}
private void Update()
{
if(renderer.isVisible && Input.GetMouseButton(0))
{
Vector3 camPos = Camera.main.WorldToScreenPoint(transform.position);
camPos.y = CameraOperator.InvertMouseY(camPos.y);
selected = CameraOperator.selection.Contains(camPos);
}
if(selected)
lightRing.enabled = true;
else
lightRing.enabled = false;
if(renderer.isVisible && lightRing.enabled == false && Input.GetMouseButtonUp(0))
{
ConfirmCommand();
}
}
private void ConfirmCommand()
{
audio.PlayOneShot(YesSir);
}
}
The 2nd issue is the more Units I select the quieter the sound clip plays! (one or two units is fine, 3 - 5 its barely audible and 6 or more and you just cant hear anything)
Why is the volume apparently being shared between the number of units?
Any ideas please guys ???