Some sound edit

This commit is contained in:
haitem 2021-01-31 15:51:03 +01:00
parent 93e4d21108
commit 2dbeaa26b4
2 changed files with 14 additions and 4 deletions

View File

@ -22,13 +22,15 @@ public class AudioManager : MonoBehaviour
} }
// Update is called once per frame // 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); AudioSound s = Array.Find(clips, sound => sound.name == name);
if (s == null) { if (s == null) {
return; return;
} }
Debug.Log("Sound is playng"); Debug.Log("Sound is playng");
if (!s.source.isPlaying || !checkIfPlay) {
s.source.Play(); s.source.Play();
} }
}
} }

View File

@ -249,7 +249,6 @@ public class PlayerManager : MonoBehaviour
if (Input.GetAxis("Horizontal") > 0) if (Input.GetAxis("Horizontal") > 0)
{ {
playerAnimator.SetBool("Walk", true); playerAnimator.SetBool("Walk", true);
FindObjectOfType<AudioManager>().Play("Walk");
if (pushPullObject == null) { if (pushPullObject == null) {
playerAnimator.transform.rotation = Quaternion.Lerp( playerAnimator.transform.rotation = Quaternion.Lerp(
playerAnimator.transform.rotation, playerAnimator.transform.rotation,
@ -261,7 +260,6 @@ public class PlayerManager : MonoBehaviour
else if (Input.GetAxis("Horizontal") < 0) else if (Input.GetAxis("Horizontal") < 0)
{ {
playerAnimator.SetBool("Walk", true); playerAnimator.SetBool("Walk", true);
FindObjectOfType<AudioManager>().Play("Walk");
if (pushPullObject == null) if (pushPullObject == null)
{ {
playerAnimator.transform.rotation = Quaternion.Lerp( playerAnimator.transform.rotation = Quaternion.Lerp(
@ -279,6 +277,16 @@ public class PlayerManager : MonoBehaviour
void Move() void Move()
{ {
if (Input.GetAxis("Horizontal") != 0)
{
if (!run) {
FindObjectOfType<AudioManager>().Play("Walk", true);
}
else
{
FindObjectOfType<AudioManager>().Play("Run", true);
}
}
rigidBody.MovePosition( rigidBody.MovePosition(
transform.position + transform.position +
(onLadder && activeAbility.Count > 0 && activeAbility[0] == 4 ? (transform.up * speed * Input.GetAxis("Vertical") * Time.deltaTime) : Vector3.zero) + (onLadder && activeAbility.Count > 0 && activeAbility[0] == 4 ? (transform.up * speed * Input.GetAxis("Vertical") * Time.deltaTime) : Vector3.zero) +