Add dashVelocity when moving

This commit is contained in:
2024-10-21 23:39:15 -07:00
parent 56dfcaf2aa
commit f2912e3d53
2 changed files with 3 additions and 2 deletions

View File

@@ -113,6 +113,7 @@ MonoBehaviour:
dashDistance: 5
dashCooldownSeconds: 5
lastAttackTime: 0
lastDashTime: 0
--- !u!50 &-4152331571693237436
Rigidbody2D:
serializedVersion: 5

View File

@@ -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<Rigidbody2D>();
@@ -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);
}
}