diff --git a/Assets/Scripts/PlayerBehavior.cs b/Assets/Scripts/PlayerBehavior.cs index 90d02fc..ad46892 100644 --- a/Assets/Scripts/PlayerBehavior.cs +++ b/Assets/Scripts/PlayerBehavior.cs @@ -20,6 +20,10 @@ public class PlayerBehavior : MonoBehaviour [Header("Clarinet:")] bool unlockedClarinet; + [SerializeField] private float dashMult = 2; + [SerializeField] private float maxDashTime = 1.0f; + [SerializeField] private float dashStopSpeed = 0.1f; + private float currentDashTime; [Header("Grappling:")] [SerializeField] public Tutorial_GrapplingGun grapplingGun; @@ -58,6 +62,8 @@ public class PlayerBehavior : MonoBehaviour void Start() { gameUI.ResetInstrumentUI(); + // for clarinet + currentDashTime = maxDashTime; } void Update() @@ -92,8 +98,19 @@ public class PlayerBehavior : MonoBehaviour { if (playerInput.actions["ClarinetDive"].WasPressedThisFrame()) { - UseClarinet(); + currentDashTime = 0.0f; } + if (!playerController.IsGrounded()) + { + Vector2 dashSpeed = new Vector2(1f,1f) * dashMult; + if (currentDashTime < maxDashTime) + { + _rb.AddForce(dashSpeed, ForceMode2D.Force); + currentDashTime += dashStopSpeed; + print("cdt " + currentDashTime); + } + // print("Clarinet pressed!"); + } } } @@ -130,7 +147,7 @@ public class PlayerBehavior : MonoBehaviour } - void FlipScale() { // DOENST WORK RIGHT + void FlipScale() { // DOENST WORK RIGHT (that's so sad for you) Vector3 currentScale = this.gameObject.transform.localScale; currentScale.x *= -1; this.gameObject.transform.localScale = currentScale; @@ -140,17 +157,6 @@ public class PlayerBehavior : MonoBehaviour GetComponent().flipX = !GetComponent().flipX; } - void UseClarinet() - { - // if key pressed J - // launch down at 45 degree angle - // use: player facing, velocity, start dash function, end dash function - if (!playerController.IsGrounded()) - { - // - } - } - void ThrowTambourine() { if (unlockedTambourine && hasTambourine && !grapplingRope.isGrappling) {