Implement dash in a slightly more sensible way
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using System.Collections;
|
||||||
|
|
||||||
public class Teo : MonoBehaviour
|
public class Teo : MonoBehaviour
|
||||||
{
|
{
|
||||||
@@ -34,7 +35,7 @@ public class Teo : MonoBehaviour
|
|||||||
Attack();
|
Attack();
|
||||||
lastAttackTime = Time.fixedTime;
|
lastAttackTime = Time.fixedTime;
|
||||||
}
|
}
|
||||||
if (Input.GetMouseButtonDown(1)) {
|
if (Input.GetMouseButtonDown(1) && Time.fixedTime-lastDashTime > dashCooldownSeconds) {
|
||||||
StartCoroutine("Dash");
|
StartCoroutine("Dash");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -58,8 +59,7 @@ public class Teo : MonoBehaviour
|
|||||||
ratbot.Damage(damageStrength);
|
ratbot.Damage(damageStrength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void Dash() {
|
IEnumerator Dash() {
|
||||||
if (Time.fixedTime-lastDashTime < dashCooldownSeconds) return;
|
|
||||||
BoxCollider2D collider = GetComponent<BoxCollider2D>();
|
BoxCollider2D collider = GetComponent<BoxCollider2D>();
|
||||||
lastDashTime = Time.fixedTime;
|
lastDashTime = Time.fixedTime;
|
||||||
collider.enabled = false;
|
collider.enabled = false;
|
||||||
@@ -68,9 +68,7 @@ public class Teo : MonoBehaviour
|
|||||||
Input.mousePosition.x - Screen.width/2,
|
Input.mousePosition.x - Screen.width/2,
|
||||||
Input.mousePosition.y - Screen.height/2
|
Input.mousePosition.y - Screen.height/2
|
||||||
).normalized * dashDistance);
|
).normalized * dashDistance);
|
||||||
Debug.Log("before");
|
yield return new WaitForSeconds(0.5F);
|
||||||
new WaitForSeconds(2F);
|
|
||||||
Debug.Log("after");
|
|
||||||
controller.linearDamping = 15;
|
controller.linearDamping = 15;
|
||||||
collider.enabled = true;
|
collider.enabled = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user