fixed footsteps

also @bryanna i moved the grapple poles in the village so they can be reached without the trumpet jump
This commit is contained in:
Sam
2023-05-01 15:06:45 -07:00
parent d2d10f064b
commit d1528cc6ff
4 changed files with 40 additions and 31 deletions

View File

@@ -90,18 +90,6 @@ public class PlayerMovement : MonoBehaviour
} else {
this._moveInput = Vector2.zero;
}
if (!IsJumping && !_isJumpFalling && !isRegFalling && value.Get<Vector2>().x != 0) {
if (!soundPlaying) {
print("footsteps PLAY");
audioSource.Play();
soundPlaying = true;
}
} else if (audioSource.isPlaying && audioSource.clip.name == "footsteps") {
print("footsteps stop");
audioSource.Stop();
soundPlaying = false;
}
}
void OnJump()
@@ -227,6 +215,14 @@ public class PlayerMovement : MonoBehaviour
gameObject.transform.Find("Trumpet").GetComponent<AudioSource>().Play();
}
}
// stop sound if needed
if (soundPlaying && (isRegFalling || IsJumping || _isJumpFalling)) {
print("footsteps stop");
audioSource.Stop();
soundPlaying = false;
}
//WALL JUMP
// else if (CanWallJump() && LastPressedJumpTime > 0)
// {
@@ -292,6 +288,20 @@ public class PlayerMovement : MonoBehaviour
SetGravityScale(Data.gravityScale);
}
#endregion
#region SOUND CHECKS
if (!IsJumping && !_isJumpFalling && !isRegFalling && _moveInput.x != 0) {
if (!soundPlaying) {
// print("footsteps PLAY");
audioSource.Play();
soundPlaying = true;
}
} else if (soundPlaying && audioSource.clip.name == "footsteps") {
// print("footsteps stop");
audioSource.Stop();
soundPlaying = false;
}
#endregion
}
private void FixedUpdate()
@@ -380,15 +390,6 @@ public class PlayerMovement : MonoBehaviour
//Convert this to a vector and apply to rigidbody
RB.AddForce(movement * Vector2.right, ForceMode2D.Force);
// play sound
// if (!IsJumping && movement != 0) {
// if (!audioSource.isPlaying) {
// audioSource.Play();
// }
// } else if (audioSource.isPlaying && audioSource.clip.name == "footsteps") {
// audioSource.Stop();
// }
/*
* For those interested here is what AddForce() will do
* RB.velocity = new Vector2(RB.velocity.x + (Time.fixedDeltaTime * speedDif * accelRate) / RB.mass, RB.velocity.y);