From 716036bc1f03f7e5187c6bfaffc2b7899328ea8e Mon Sep 17 00:00:00 2001 From: slevy14 Date: Thu, 27 Apr 2023 19:47:39 -0700 Subject: [PATCH] moved trumpet jump to new player controller this should work, though i'm still not 100% sure how the new jump works --- Assets/Scripts/PlayerController.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Assets/Scripts/PlayerController.cs b/Assets/Scripts/PlayerController.cs index dd2abe5..3c7dc7f 100644 --- a/Assets/Scripts/PlayerController.cs +++ b/Assets/Scripts/PlayerController.cs @@ -101,7 +101,7 @@ public class PlayerMovement : MonoBehaviour if (!IsJumping) { //Ground Check - if (Physics2D.OverlapBox(this.transform.position, _groundCheckSize, 0, _groundLayer) && !IsJumping) //checks if set box overlaps with ground + if (IsGrounded()) //checks if set box overlaps with ground { LastOnGroundTime = Data.coyoteTime; //if so sets the lastGrounded to coyoteTime trumpet = true; @@ -151,6 +151,13 @@ public class PlayerMovement : MonoBehaviour _isJumpCut = false; _isJumpFalling = false; Jump(); + if (!IsGrounded() && in_range && trumpet) { + Destroy(enemy.gameObject); + enemy = null; + in_range = false; + } else if (!IsGrounded() && !in_range && trumpet) { + trumpet = false; + } } //WALL JUMP // else if (CanWallJump() && LastPressedJumpTime > 0) @@ -209,6 +216,7 @@ public class PlayerMovement : MonoBehaviour SetGravityScale(Data.gravityScale); } #endregion + } } private void FixedUpdate() @@ -380,6 +388,9 @@ public class PlayerMovement : MonoBehaviour private bool CanJump() { + if (!IsGrounded() && trumpet) { + return true; + } return LastOnGroundTime > 0 && !IsJumping; } @@ -406,6 +417,10 @@ public class PlayerMovement : MonoBehaviour else return false; } + + public bool IsGrounded() { + return (Physics2D.OverlapBox(this.transform.position, _groundCheckSize, 0, _groundLayer) && !IsJumping); + } #endregion