Newer
Older
Dreamsturbia-Project-IADE-Unity3D / Assets / Scripts / Player / PlayerAnimationSounds.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerAnimationSounds : MonoBehaviour
{
    [SerializeField] private AudioClip[] footsteps; 
    [SerializeField] private AudioClip[] sounds;
    private AudioSource animationSoundPlayer;

    // Start is called before the first frame update
    void Start()
    {
        animationSoundPlayer = GetComponent<AudioSource>();
        Debug.Log(animationSoundPlayer);
    }


    private void FootStepSound()
    {
        animationSoundPlayer.clip = RandomSounds(footsteps);
        animationSoundPlayer.Play();
    }

    private void JumpSound()
    {
        animationSoundPlayer.clip = sounds[0];
        animationSoundPlayer.Play();
    }

    private void PunchSound()
    {
        animationSoundPlayer.clip = sounds[0];
        animationSoundPlayer.Play();
    }

    private void Dash()
    {
        animationSoundPlayer.clip = sounds[1];
        animationSoundPlayer.Play();
    }

    private void Dance()
    {
        //animationSoundPlayer.clip = audioClips[2];
        animationSoundPlayer.Play();
    }

    private AudioClip RandomSounds(AudioClip [] soundArray)
    {
        return soundArray[Random.Range(0, soundArray.Length)];
    }
}