Hello,
Im trying to turn off an audio clip from a different Gameobject by clicking the game object when triggered, but i cant seem to get it to work
Currently, I have a method that randomly selects a phone to start ringing
public GameObject phoneA;
public GameObject phoneB;
public GameObject phoneC;
public GameObject phoneD;
public GameObject phoneE;
GameObject[ ] ringer;
GameObject selectedPhone;
int index;
public void PhoneSelector ()
{
if (countDownTimer > 0)
{
ringer = GameObject.FindGameObjectsWithTag(“phone”);
index = Random.Range (0, ringer.Length);
selectedPhone = ringer[index];
selectedPhone.audio.Play();
print (selectedPhone.name);
}
}
and i have 5 phones lined up with each game object has its own audioclip that plays
how do i get a input.GetMouseButtonDown function to turn this phone ringing off?
i current have it like this but it only recognizes the Phonemanager gameobject, which is the parent of all 5 phones
if(Input.GetMouseButtonDown(0))
{
print (gameObject.name);
if (gameObject.audio.clip)
{
audio.Play();
Debug.Log(“audio is working”);
}
{
Can someone help me understand how you can access the actual gameobject thats ringing, so that i can tell it to stop ringing
Your help will be much appreciated