diff --git a/Assets/Scripts/AudioManager.cs b/Assets/Scripts/AudioManager.cs index 067a47e..baae306 100644 --- a/Assets/Scripts/AudioManager.cs +++ b/Assets/Scripts/AudioManager.cs @@ -22,13 +22,15 @@ public class AudioManager : MonoBehaviour } // Update is called once per frame - public void Play(string name) + public void Play(string name, bool checkIfPlay = false) { AudioSound s = Array.Find(clips, sound => sound.name == name); if (s == null) { return; } Debug.Log("Sound is playng"); - s.source.Play(); + if (!s.source.isPlaying || !checkIfPlay) { + s.source.Play(); + } } } diff --git a/Assets/Scripts/PlayerManager.cs b/Assets/Scripts/PlayerManager.cs index bd9d7e9..1a80c9d 100644 --- a/Assets/Scripts/PlayerManager.cs +++ b/Assets/Scripts/PlayerManager.cs @@ -249,7 +249,6 @@ public class PlayerManager : MonoBehaviour if (Input.GetAxis("Horizontal") > 0) { playerAnimator.SetBool("Walk", true); - FindObjectOfType().Play("Walk"); if (pushPullObject == null) { playerAnimator.transform.rotation = Quaternion.Lerp( playerAnimator.transform.rotation, @@ -261,7 +260,6 @@ public class PlayerManager : MonoBehaviour else if (Input.GetAxis("Horizontal") < 0) { playerAnimator.SetBool("Walk", true); - FindObjectOfType().Play("Walk"); if (pushPullObject == null) { playerAnimator.transform.rotation = Quaternion.Lerp( @@ -279,6 +277,16 @@ public class PlayerManager : MonoBehaviour void Move() { + if (Input.GetAxis("Horizontal") != 0) + { + if (!run) { + FindObjectOfType().Play("Walk", true); + } + else + { + FindObjectOfType().Play("Run", true); + } + } rigidBody.MovePosition( transform.position + (onLadder && activeAbility.Count > 0 && activeAbility[0] == 4 ? (transform.up * speed * Input.GetAxis("Vertical") * Time.deltaTime) : Vector3.zero) +