- Home /
Smooth dashing issues
Hello everyone, I'm trying to create a dash script for my 2.5d (3d sidescroller) character in Unity, I managed to create the dash animation, limit air dash to 1 and also dash on the ground (which will need a bit more tweaking), however I'm having problems in making the dash go smooth. For reference here is the dash part of my code (it's in fixedupdate, but it gives me the same result in update):
void Dashing()
{
if (isGrounded)
{
if(Input.GetButtonDown("Fire3") && canDash)
{
if (facingRight)
{
rb.velocity = new Vector3(0, 0, 0);
rb.AddForce(Vector3.right * dashForce, ForceMode.Impulse);
anim.Play("Dash");
}
if (!facingRight)
{
rb.velocity = new Vector3(0, 0, 0);
rb.AddForce(Vector3.left * dashForce, ForceMode.Impulse);
anim.Play("Dash");
}
}
canDash = true;
}
if (!isGrounded)
{
if (Input.GetButtonDown("Fire3") && canDash)
{
if (facingRight)
{
rb.velocity = new Vector3(0, 0, 0);
rb.AddForce(Vector3.right * dashForce, ForceMode.Impulse);
anim.Play("Dash");
canDash = false;
}
if (!facingRight)
{
rb.velocity = new Vector3(0, 0, 0);
rb.AddForce(Vector3.left * dashForce, ForceMode.Impulse);
anim.Play("Dash");
canDash = false;
}
}
}
}
I'm using rigidbody, and tried to make dash the same way jump worked, my jump uses
rb.AddForce(Vector3.up * jumpForce, ForceMode.Impulse);
So I thought I could make a smooth dash the same way, but unsuccessful. It's a dash with almost no travel time, looks pretty unsettling. I've tried looking for answers here and found nothing really helpful.
Should I change the dash method or is there a way to use rigidbody to make this smooth dash work?
Your answer
Follow this Question
Related Questions
Making RB movement smoother/curvy. C#. 1 Answer
Making a bubble level (not a game but work tool) 1 Answer
RigidBody immediately stops after AddForce 1 Answer
Problem with movement 0 Answers
Adding 1 frame of force 2 Answers