Why am I dropping during my dash? (work around found, but not solved)

Ive got an air dash that is supposed to turn off gravity, zero linear velocity, dash, then turn on gravity and zero velocity when its over.

Problem is I’m dropping about a half meter at the start and stop.

Any ideas?

    void Dodge()
    {
        if (dashTimer > 0) dashTimer -= Time.deltaTime;
        if (dashTimer < 0 && isDashing)
        {
            Debug.Log("STOP! " + myRigidbody.position.y);
            myRigidbody.linearVelocity = new Vector3(0, 0, 0);
            myRigidbody.useGravity = true;
            isDashing = false;
            isFalling = true;
            return;
        }
        if (dodge.action.WasPressedThisFrame())
        {
            if (isGrounded && !isDashing)
            {
                //Debug.Log("PARKOUR!");
                isDashing = true;
                isFalling = false;
                dashTimer = 0.1f;
                if (isFacingRight) myRigidbody.linearVelocity = new Vector3(quickstepX, quickstepY, 0);
                if (!isFacingRight) myRigidbody.linearVelocity = new Vector3(-quickstepX, quickstepY, 0);
                return;
            }

            if (!isGrounded && !isDashing && playerStatus.airDash)
            {
                Debug.Log("START! " + myRigidbody.position.y);
                myRigidbody.useGravity = false;
                isDashing = true;
                isFalling = false;
                dashTimer = 0.1f;
                if (isFacingRight) myRigidbody.linearVelocity = new Vector3(quickstepX, 0, 0);
                if (!isFacingRight) myRigidbody.linearVelocity = new Vector3(-quickstepX, 0, 0);
                return;
            }
        }
    }

EDIT: I ended up freezing Y position, but I’m still baffled why it would drop.

Can you be sure that you don’t have any other scripts affecting the movement?

Usually when I get something like this, it’s usually a coroutine that I think was supposed to have exited, but it’s still going.

1 Like