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

View File

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