Refactor: Dash

Repositioned some parts of dash code into skillHandler
This commit is contained in:
2025-08-28 17:09:35 +02:00
parent 25ff65c0b3
commit dc083bfc93
3 changed files with 21 additions and 19 deletions

View File

@@ -4,24 +4,31 @@ using UnityEngine;
public class PlayerSkillHandler
{
private float dashSpeed = 15f;
private float dashDuration = 0.2f;
private float dashSpeed;
private float dashDuration;
private bool isDashing = false;
public bool IsDashing() { return isDashing; }
public PlayerSkillHandler(float dashSpeed, float dashDuration)
{
this.dashSpeed = dashSpeed;
this.dashDuration = dashDuration;
}
public IEnumerator DashCoroutine(CharacterController controller, Vector3 direction)
{
Physics.IgnoreLayerCollision(6, 7, true); // disable collisions between player and enemies
float startTime = Time.time;
isDashing = true;
isDashing = true; // just for now. maybe will be removed
while (Time.time - startTime < dashDuration)
{
controller.Move(direction * dashSpeed * Time.deltaTime);
yield return null;
controller.Move(dashSpeed * Time.deltaTime * direction);
yield return null; // wait one frame
}
isDashing = false;
isDashing = false; // just for now. maybe will be removed
Physics.IgnoreLayerCollision(6, 7, false); // enable collisions between player and enemies
}
}