// Use this for initialization private void Start() { audioHandler = GetComponent <PlayerAudioHandler>(); rb = GetComponent <Rigidbody>(); distToGround = GetComponent <Collider>().bounds.extents.y; state = State.MIDDLE; }
//OnStateEnter is called when a transition starts and the state machine starts to evaluate this state override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { animator.SetBool("Jumped", false); audio = animator.GetComponent <PlayerAudioHandler>(); if (audio.jumpAudioSource) { audio.jumpAudioSource.PlayOneShot(jumpSound); } }
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { if (!audio) { audio = animator.GetComponent <PlayerAudioHandler>(); audio.walkAudioSource.clip = walkingSound; audioVolume = audio.walkAudioSource.volume; audio.walkAudioSource.volume = 0.0f; audio.walkAudioSource.Play(); } }