Guest User

Untitled

a guest
May 24th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. public class KnightAudio : MonoBehaviour {
  2.  
  3. //private Animator anim;
  4. private NavMeshAgent agent;
  5.  
  6. private AudioSource knightAudio;
  7. public AudioClip crying; //set this in ispector with audiofile
  8. public AudioClip scream; //set this in ispector with audiofile
  9.  
  10. // Use this for initialization
  11. void Start () {
  12. knightAudio = GetComponent<AudioSource>();
  13. agent = GetComponent<NavMeshAgent>();
  14. //anim = GetComponent<Animator>();
  15. }
  16.  
  17. // Update is called once per frame
  18. void Update () {
  19. if (!agent.isStopped)
  20. {
  21. knightAudio.clip = scream;
  22. knightAudio.Play();
  23. }
  24. else
  25. {
  26. knightAudio.clip = crying;
  27. knightAudio.Play();
  28. }
  29.  
  30. }
  31. }
Add Comment
Please, Sign In to add comment