switch (dashState)
{
case DashState.Ready:
var isDashKeyDown = Input.GetButtonDown("Dash");
if (isDashKeyDown)
{
savedVelocity = rigid.velocity;
rigid.velocity = new Vector2(rigid.velocity.x * 3f, rigid.velocity.y);
dashState = DashState.Dashing;
}
break;
case DashState.Dashing:
dashTimer += Time.deltaTime * 3;
if (dashTimer >= maxDash)
{
dashTimer = maxDash;
rigid.velocity = savedVelocity;
dashState = DashState.Cooldown;
}
break;
case DashState.Cooldown:
dashTimer -= Time.deltaTime;
if (dashTimer <= 0)
{
dashTimer = 0;
dashState = DashState.Ready;
}
break;
}
이렇게 해서 쿨타임넣고 했는데 문제는 안움직이네여
상태창 확인해보면 쿨타임으로 켜지고꺼지고는 되는데 정작 움직이질 않아요
rigid.velocity = new Vector2(rigid.velocity.x * 3f, rigid.velocity.y);
이부분이 문제인거같은데 여기에 아예 rigid.velocity.x를 지우고 상수를 넣으면 한쪽으로만 움직여버려서 고민입니다.
아예 스위치문에 case를 한개 더 넣어서 오른쪽으로 움직일때, 왼쪽으로 움직일때 나눠서 하는것도 생각해봤는데 좀 더 쉽게 해결할 방법이 있을까요?
스위치말고 걍 if문으로 해보지 그러냐