- Home /
Question by
JunCon · Aug 03, 2020 at 11:21 AM ·
2d2d game2d-platformerdash
I need help with my dash
i saw a lot of videos in youtube but i still cant dash. when i press the button to dash, it looks like my player is gliding in the air. can somebody help me?
void Dash() {
if (direction == 0)
{
resetDash -= Time.deltaTime;
if (Input.GetButtonDown("Fire3"))
{
isDashing = true;
if (moveInput <= 0)
{
direction = 1;
}
else if (moveInput >= 0)
{
direction = 2;
}
}
else if (Input.GetButtonUp("Fire3"))
{
isDashing = false;
}
}
else
{
if (dashTime <= 0)
{
direction = 0;
dashTime = startDashTime;
if (resetDash >= 0)
{
rb.velocity = Vector2.zero;
isDashing = false;
}
}
else
{
dashTime -= Time.deltaTime;
if (resetDash <= 0)
{
if (direction == 1)
{
rb.velocity = new Vector2(moveInput * dashSpeed, rb.velocity.y);
resetDash = startResetDash;
isDashing = true;
}
else if (direction == 2)
{
rb.velocity = new Vector2(moveInput * dashSpeed, rb.velocity.y);
resetDash = startResetDash;
isDashing = true;
}
}
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Huge lag when toggling between Tile maps in one scene. 0 Answers
What is the best/easiest way to align a 2D rigidbody to specific sections of a sprite? 1 Answer
Why is there a gap between my player and the wall during wall slide? SOLVED 2 Answers
Problem with akward wave "Rendering",Tilemap/Grid akward wave effect 0 Answers
My 2D tiles have holes in them 0 Answers