Add dashVelocity when moving
This commit is contained in:
@@ -113,6 +113,7 @@ MonoBehaviour:
|
|||||||
dashDistance: 5
|
dashDistance: 5
|
||||||
dashCooldownSeconds: 5
|
dashCooldownSeconds: 5
|
||||||
lastAttackTime: 0
|
lastAttackTime: 0
|
||||||
|
lastDashTime: 0
|
||||||
--- !u!50 &-4152331571693237436
|
--- !u!50 &-4152331571693237436
|
||||||
Rigidbody2D:
|
Rigidbody2D:
|
||||||
serializedVersion: 5
|
serializedVersion: 5
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ public class Teo : MonoBehaviour
|
|||||||
public float lastDashTime = 0;
|
public float lastDashTime = 0;
|
||||||
Rigidbody2D controller;
|
Rigidbody2D controller;
|
||||||
GameState gameState;
|
GameState gameState;
|
||||||
|
Vector2 dashVelocity;
|
||||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||||
void Start() {
|
void Start() {
|
||||||
controller = GetComponent<Rigidbody2D>();
|
controller = GetComponent<Rigidbody2D>();
|
||||||
@@ -27,7 +28,7 @@ public class Teo : MonoBehaviour
|
|||||||
controller.linearVelocity = new Vector2 (
|
controller.linearVelocity = new Vector2 (
|
||||||
Input.GetAxis("Horizontal"),
|
Input.GetAxis("Horizontal"),
|
||||||
Input.GetAxis("Vertical")
|
Input.GetAxis("Vertical")
|
||||||
).normalized * moveSpeed;
|
).normalized * moveSpeed + dashVelocity;
|
||||||
// Attack on click if not on cooldown
|
// Attack on click if not on cooldown
|
||||||
if (Input.GetMouseButtonDown(0)) {
|
if (Input.GetMouseButtonDown(0)) {
|
||||||
Attack();
|
Attack();
|
||||||
@@ -65,6 +66,5 @@ public class Teo : MonoBehaviour
|
|||||||
Input.mousePosition.y - Screen.height/2,
|
Input.mousePosition.y - Screen.height/2,
|
||||||
0
|
0
|
||||||
).normalized * dashDistance;
|
).normalized * dashDistance;
|
||||||
Debug.Log(controller.linearVelocity);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user