Okay so this is my first post. Anyway I made a script:
using UnityEngine;
using System.Collections;
public class MusicOnOff : MonoBehaviour
{
private bool Trigger = false;
public GameObject Button;
public GameObject Speaker;
Transform DoorGameObject;
private bool HasTriggerBeenUsed = false;
void OnTriggerStay ()
{
if (Input.GetKeyDown("f") && !HasTriggerBeenUsed)
{
// toggle audio on/off on audiosource of speakers
AudioSource source = Speaker.GetComponent<AudioSource>();
source.enabled = !source.enabled;
{
Trigger = true;
if (Trigger)
Button.animation.Play ("Buttondown");
}
}
}
}
and where it says: Button.animation.Play (“Buttondown”);
I want to be able to edit the animation so it can be changed easily like making it a public GameObject kind of and the script would not have to be edited. If this can’t be done I can always try something else though.
The script also may not be great it is my first script made by myself it was probably one of the simplest things I could make so if it could be left the way it is it would also be appreciated.