From 3aa0823bbeb2c3f08445bfe6f47d5055bf2160e0 Mon Sep 17 00:00:00 2001 From: allylikesfrogs Date: Wed, 3 May 2023 00:35:59 -0700 Subject: [PATCH] ugh --- Assets/Scripts/PlayerBehavior.cs | 24 +++++++++++++++--------- Assets/Scripts/PlayerController.cs | 12 ++++++++++-- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/Assets/Scripts/PlayerBehavior.cs b/Assets/Scripts/PlayerBehavior.cs index ad46892..aec78f1 100644 --- a/Assets/Scripts/PlayerBehavior.cs +++ b/Assets/Scripts/PlayerBehavior.cs @@ -21,9 +21,10 @@ public class PlayerBehavior : MonoBehaviour [Header("Clarinet:")] bool unlockedClarinet; [SerializeField] private float dashMult = 2; - [SerializeField] private float maxDashTime = 1.0f; + [SerializeField] private float maxDashTime = 10.0f; [SerializeField] private float dashStopSpeed = 0.1f; private float currentDashTime; + public bool isDash = false; [Header("Grappling:")] [SerializeField] public Tutorial_GrapplingGun grapplingGun; @@ -98,19 +99,24 @@ public class PlayerBehavior : MonoBehaviour { if (playerInput.actions["ClarinetDive"].WasPressedThisFrame()) { + isDash = true; currentDashTime = 0.0f; } if (!playerController.IsGrounded()) + { + Vector3 dashSpeed = new Vector3(1f,1f,1f) * dashMult; + if (currentDashTime < maxDashTime) { - Vector2 dashSpeed = new Vector2(1f,1f) * dashMult; - if (currentDashTime < maxDashTime) - { - _rb.AddForce(dashSpeed, ForceMode2D.Force); - currentDashTime += dashStopSpeed; - print("cdt " + currentDashTime); - } - // print("Clarinet pressed!"); + _rb.AddForce(dashSpeed, ForceMode2D.Force); + currentDashTime += dashStopSpeed; + print("cdt " + currentDashTime); } + else + { + isDash = false; + } + } + else{isDash = false;} } } diff --git a/Assets/Scripts/PlayerController.cs b/Assets/Scripts/PlayerController.cs index c0dea09..4282730 100644 --- a/Assets/Scripts/PlayerController.cs +++ b/Assets/Scripts/PlayerController.cs @@ -50,6 +50,9 @@ public class PlayerMovement : MonoBehaviour bool wasGrappling = false; bool unlockedTrumpet; + //clarinet + public bool isDashing = false; + //Set all of these up in the inspector [Header("Checks")] //Size of groundCheck depends on the size of your character generally you want them slightly small than width (for ground) and height (for the wall check) @@ -88,7 +91,7 @@ public class PlayerMovement : MonoBehaviour void OnMove(InputValue value) { - if (playerBehavior.playerIsAlive) { + if (playerBehavior.playerIsAlive && !isDashing) { this._moveInput = value.Get(); } else { this._moveInput = Vector2.zero; @@ -97,13 +100,15 @@ public class PlayerMovement : MonoBehaviour void OnJump() { - if (playerBehavior.playerIsAlive) { + if (playerBehavior.playerIsAlive && !isDashing) { OnJumpInput(); } } private void Update() { + isDashing = playerBehavior.isDash; + if(!isDashing){ unlockedTrumpet = stateController.unlockedTrumpet; #region TIMERS LastOnGroundTime -= Time.deltaTime; @@ -313,10 +318,12 @@ public class PlayerMovement : MonoBehaviour gameUI.ToggleTrumpet(false); } #endregion + } } private void FixedUpdate() { + if(!isDashing){ //Handle Run if (IsWallJumping) Run(Data.wallJumpRunLerp); @@ -326,6 +333,7 @@ public class PlayerMovement : MonoBehaviour //Handle Slide if (IsSliding) Slide(); + } } #region INPUT CALLBACKS