added footsteps!
need to move the call from OnMove to Run, still some bugfixing to do
This commit is contained in:
@@ -29,12 +29,22 @@ public class PlayerBehavior : MonoBehaviour
|
||||
|
||||
Animator animator;
|
||||
[HideInInspector] public bool playerIsAlive = true;
|
||||
|
||||
[Header("Sound")]
|
||||
[SerializeField] public AudioClip footstepSound;
|
||||
[SerializeField] public AudioClip deathSound;
|
||||
AudioSource audioSource;
|
||||
|
||||
|
||||
void Start()
|
||||
{
|
||||
{ // initialize
|
||||
_rb = GetComponent<Rigidbody2D>();
|
||||
stateController = GameObject.Find("StateController").GetComponent<StateController>();
|
||||
|
||||
audioSource = this.gameObject.GetComponent<AudioSource>();
|
||||
audioSource.clip = footstepSound;
|
||||
audioSource.loop = true;
|
||||
|
||||
animator = GetComponent<Animator>();
|
||||
GameObject.Find("Main Camera").GetComponent<CameraMovement>().player = this.gameObject;
|
||||
playerIsAlive = true;
|
||||
@@ -204,13 +214,14 @@ public class PlayerBehavior : MonoBehaviour
|
||||
if (playerIsAlive) {
|
||||
print("destroyPlayer called");
|
||||
playerIsAlive = false;
|
||||
AudioSource audio = this.gameObject.GetComponent<AudioSource>();
|
||||
audio.Play();
|
||||
audioSource.clip = deathSound;
|
||||
audioSource.loop = false;
|
||||
audioSource.Play();
|
||||
|
||||
// animate
|
||||
animator.Play("Die");
|
||||
// yield return new WaitForSeconds(animator.GetCurrentAnimatorStateInfo(0).length);
|
||||
yield return new WaitForSeconds(audio.clip.length);
|
||||
yield return new WaitForSeconds(audioSource.clip.length);
|
||||
|
||||
// this.stateController.SetDeathCanvasActive(true);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user