Add dashVelocity when moving
This commit is contained in:
@@ -113,6 +113,7 @@ MonoBehaviour:
|
||||
dashDistance: 5
|
||||
dashCooldownSeconds: 5
|
||||
lastAttackTime: 0
|
||||
lastDashTime: 0
|
||||
--- !u!50 &-4152331571693237436
|
||||
Rigidbody2D:
|
||||
serializedVersion: 5
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user