From f2912e3d5314afd0c76a3aeae8252e6b0e47f80f Mon Sep 17 00:00:00 2001 From: ProtoSharkk Date: Mon, 21 Oct 2024 23:39:15 -0700 Subject: [PATCH] Add dashVelocity when moving --- Assets/Player.prefab | 1 + Assets/Teo.cs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Assets/Player.prefab b/Assets/Player.prefab index 19fd7c5..63645b0 100644 --- a/Assets/Player.prefab +++ b/Assets/Player.prefab @@ -113,6 +113,7 @@ MonoBehaviour: dashDistance: 5 dashCooldownSeconds: 5 lastAttackTime: 0 + lastDashTime: 0 --- !u!50 &-4152331571693237436 Rigidbody2D: serializedVersion: 5 diff --git a/Assets/Teo.cs b/Assets/Teo.cs index 144a025..9cb9384 100644 --- a/Assets/Teo.cs +++ b/Assets/Teo.cs @@ -15,6 +15,7 @@ public class Teo : MonoBehaviour public float lastDashTime = 0; Rigidbody2D controller; GameState gameState; + Vector2 dashVelocity; // Start is called once before the first execution of Update after the MonoBehaviour is created void Start() { controller = GetComponent(); @@ -27,7 +28,7 @@ public class Teo : MonoBehaviour controller.linearVelocity = new Vector2 ( Input.GetAxis("Horizontal"), Input.GetAxis("Vertical") - ).normalized * moveSpeed; + ).normalized * moveSpeed + dashVelocity; // Attack on click if not on cooldown if (Input.GetMouseButtonDown(0)) { Attack(); @@ -65,6 +66,5 @@ public class Teo : MonoBehaviour Input.mousePosition.y - Screen.height/2, 0 ).normalized * dashDistance; - Debug.Log(controller.linearVelocity); } }