Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class KnightAudio : MonoBehaviour {
- //private Animator anim;
- private NavMeshAgent agent;
- private AudioSource knightAudio;
- public AudioClip crying; //set this in ispector with audiofile
- public AudioClip scream; //set this in ispector with audiofile
- // Use this for initialization
- void Start () {
- knightAudio = GetComponent<AudioSource>();
- agent = GetComponent<NavMeshAgent>();
- //anim = GetComponent<Animator>();
- }
- // Update is called once per frame
- void Update () {
- if (!agent.isStopped)
- {
- knightAudio.clip = scream;
- knightAudio.Play();
- }
- else
- {
- knightAudio.clip = crying;
- knightAudio.Play();
- }
- }
- }
Add Comment
Please, Sign In to add comment