- Home /
Question by
LaddoRubik · Aug 18, 2019 at 12:43 PM ·
2d-platformerdash
2D Dash Not Working
I cant seem to dash at all, any help would be massively appreciated.
void Update()
{
if (direction == 0)
{
if (Input.GetKey(KeyCode.A))
{
direction = 1;
moveX = +1f;
}
else if (Input.GetKey(KeyCode.D))
{
direction = 2;
moveX = -1f;
}
else if (Input.GetKey(KeyCode.W))
{
direction = 3;
moveY = +1f;
}
else if (Input.GetKey(KeyCode.S))
{
direction = 4;
moveY = -1f;
}
}
else
{
if (dashTime <= 0)
{
direction = 0;
dashTime = startDashTime;
rb.velocity = Vector2.zero;
}
else
{
dashTime -= Time.deltaTime;
}
}
if (Input.GetKeyDown(KeyCode.LeftShift) && direction == 1)
{
rb.AddForce(Vector2.left * dashSpeed);
}
else if (Input.GetKeyDown(KeyCode.LeftShift) && direction == 2)
{
rb.AddForce(Vector2.right * dashSpeed);
}
else if (Input.GetKeyDown(KeyCode.LeftShift) && direction == 3)
{
rb.AddForce(Vector2.up * dashSpeed);
}
else if (Input.GetKeyDown(KeyCode.LeftShift) && direction == 4)
{
rb.AddForce(Vector2.down * dashSpeed);
}
Comment
Your answer
Follow this Question
Related Questions
Adding a Dash in a 2D sidescroller 1 Answer
AddForce problem axis X 1 Answer
Can Dash only once 2D 2 Answers
I need help with my dash 0 Answers
Able to dash in the air but NOT on the floor/standing tile 1 Answer