Example #1
0
    void StartDash()
    {
        if (canDash)
        {
            canDash        = false;
            dashInProgress = true;
            dashTimeLeft   = dashTime;

            Vector3 dashVelocity = default;
            if (dashMode == DashMode.TowardsMouse)
            {
                Vector3 towardsLookPos = input.LookAtPos - transform.position;
                dashVelocity = towardsLookPos.normalized * dashSpeed;
            }
            else if (dashMode == DashMode.TowardsVelocity)
            {
                dashVelocity = bodyMovement.Velocity.normalized * dashSpeed;
            }

            bodyMovement.Velocity = dashVelocity;
            bodyMovement.SetVelocityChangeActive(false);
        }
    }