fixed: player no longer holds grapple after dying to projectile

This commit is contained in:
Sam 2023-05-06 18:25:35 -07:00
parent dcfae28ee3
commit 9b3bc81173
2 changed files with 9 additions and 14 deletions

View File

@ -226,7 +226,7 @@ public class PlayerBehavior : MonoBehaviour
void LetGoOfGrapple() {
bool currentlyPaused = StateController.Instance.isPaused;
if (grapplingRope.isGrappling && !currentlyPaused) {
print("currently paused is " + currentlyPaused + ", releasing grapple");
// print("currently paused is " + currentlyPaused + ", releasing grapple");
if (tambourine != null) {
tambourine.GetComponent<TambourineBehavior>().DestroySelf();
}
@ -362,7 +362,10 @@ public class PlayerBehavior : MonoBehaviour
IEnumerator DestroyPlayer() {
if (playerIsAlive) {
print("destroyPlayer called");
if (grapplingRope.isGrappling) {
LetGoOfGrapple();
}
// print("destroyPlayer called");
playerIsAlive = false;
audioSource.clip = deathSound;
audioSource.loop = false;
@ -371,15 +374,8 @@ public class PlayerBehavior : MonoBehaviour
// animate
animator.Play("Die");
// yield return new WaitForSeconds(animator.GetCurrentAnimatorStateInfo(0).length);
yield return new WaitForSeconds(audioSource.clip.length);
// this.stateController.SetDeathCanvasActive(true);
if (grapplingRope.isGrappling) {
LetGoOfGrapple();
}
// destroy all tambourines
GameObject[] currentTambourines = GameObject.FindGameObjectsWithTag("tambourine");
print("tambs found: " + currentTambourines.Length);

View File

@ -287,15 +287,14 @@ public class PlayerMovement : MonoBehaviour
#region Calculate AccelRate
float accelRate;
//Gets an acceleration value based on if we are accelerating (includes turning)
//or trying to decelerate (stop). As well as applying a multiplier if we're air borne.
if (LastOnGroundTime > 0) {
// accelerate or decelerate
if (LastOnGroundTime > 0) { // if grounded
accelRate = (Mathf.Abs(targetSpeed) > 0.01f) ? Data.runAccelAmount : Data.runDeccelAmount;
}
else if (wasGrappling) {
else if (wasGrappling) { // if grappling
accelRate = (Mathf.Abs(targetSpeed) > 0.01f) ? Data.runAccelAmount * Data.accelInAir : Data.runDeccelAmount * (Data.deccelInAir / 5);
}
else {
else { // if in air
accelRate = (Mathf.Abs(targetSpeed) > 0.01f) ? Data.runAccelAmount * Data.accelInAir : Data.runDeccelAmount * Data.deccelInAir;
}
#endregion