Newer
Older
Dreamsturbia-Project-IADE-Unity3D / Assets / Scripts / Player / PlayerAnimationSounds.cs
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class PlayerAnimationSounds : MonoBehaviour
  5. {
  6. [SerializeField] private AudioClip[] footsteps;
  7. [SerializeField] private AudioClip[] sounds;
  8. private AudioSource animationSoundPlayer;
  9. // Start is called before the first frame update
  10. void Start()
  11. {
  12. animationSoundPlayer = GetComponent<AudioSource>();
  13. Debug.Log(animationSoundPlayer);
  14. }
  15. private void FootStepSound()
  16. {
  17. animationSoundPlayer.clip = RandomSounds(footsteps);
  18. animationSoundPlayer.Play();
  19. }
  20. private void JumpSound()
  21. {
  22. animationSoundPlayer.clip = sounds[0];
  23. animationSoundPlayer.Play();
  24. }
  25. private void PunchSound()
  26. {
  27. animationSoundPlayer.clip = sounds[0];
  28. animationSoundPlayer.Play();
  29. }
  30. private void Dash()
  31. {
  32. animationSoundPlayer.clip = sounds[1];
  33. animationSoundPlayer.Play();
  34. }
  35. private void Dance()
  36. {
  37. //animationSoundPlayer.clip = audioClips[2];
  38. animationSoundPlayer.Play();
  39. }
  40. private AudioClip RandomSounds(AudioClip [] soundArray)
  41. {
  42. return soundArray[Random.Range(0, soundArray.Length)];
  43. }
  44. }