My boost code doesnt move my 2D character at all.

the code is connected to the asset and i have changed the local values around and nothing seems to fix it

–the code

public class Boost : MonoBehaviour
{
private Rigidbody2D rb;
public float boostSpeed;
private float boostTime;
public float startBoostTime;
private int direction;
// Start is called before the first frame update
void Start()
{
rb = GetComponent();
boostTime = startBoostTime;
}

// Update is called once per frame
void Update()
{
    if(direction == 0)
    {
        if ((Input.GetKey(KeyCode.LeftArrow))&&(Input.GetKey(KeyCode.LeftShift)))
        {
            direction = 1;
            
        }
        else if ((Input.GetKey(KeyCode.RightArrow))&&(Input.GetKey(KeyCode.LeftShift)))
        {
            direction = 2;
        }
        else if ((Input.GetKey(KeyCode.UpArrow))&&(Input.GetKey(KeyCode.LeftShift)))
        {
            direction = 3;
        }
        else if ((Input.GetKey(KeyCode.DownArrow))&&(Input.GetKey(KeyCode.LeftShift)))
        {
            direction = 4;
        }
        else
        {
            if (boostTime <= 0)
            {
                direction = 0;
                boostTime = startBoostTime;
                rb.AddForce(Vector2.zero * boostSpeed);
            }
            else
            {
                boostTime -= Time.deltaTime;
                
                if (direction == 1)
                    
                {
                    rb.AddForce(Vector2.left * boostSpeed);
                }
                else if (direction == 2)
                {
                    rb.AddForce(Vector2.right * boostSpeed);
                }
                else if (direction == 3)
                {
                    rb.AddForce(Vector2.up * boostSpeed);
                }
                else if (direction == 4)
                {
                    rb.AddForce(Vector2.down * boostSpeed);
                }

               
            }
        }
    }
}

}

I think you forgot to add ForceMode2D.Impulse, or ForceMode2D.Force. Just pick one that works for your game and then change the AddForce() like the example below:

rb.AddForce(Vector2.up * boostSpeed, ForceMode2D.Force);

Hope that helps!

void Update()
{
if(direction == 0)
{
if ((Input.GetKey(KeyCode.LeftArrow))&&(Input.GetKey(KeyCode.LeftShift)))
{
direction = 1;

         }
         else if ((Input.GetKey(KeyCode.RightArrow))&&(Input.GetKey(KeyCode.LeftShift)))
         {
             direction = 2;
         }
         else if ((Input.GetKey(KeyCode.UpArrow))&&(Input.GetKey(KeyCode.LeftShift)))
         {
             direction = 3;
         }
         else if ((Input.GetKey(KeyCode.DownArrow))&&(Input.GetKey(KeyCode.LeftShift)))
         {
             direction = 4;
         }
      } /**<-- Add a curly bracket, to close off the outer upper "if-statement" so the following code can be accessed:**/
      else
      {
          if (boostTime <= 0)
          {
              direction = 0;
              boostTime = startBoostTime;
              rb.AddForce(Vector2.zero * boostSpeed, ForceMode2D.Impulse); //Add impulse
          }
          else
          {
              boostTime -= Time.deltaTime;
              
              if (direction == 1)
                   
              {
                  rb.AddForce(Vector2.left * boostSpeed, ForceMode2D.Impulse); //Add impulse
               }
              else if (direction == 2)
              {
                  rb.AddForce(Vector2.right * boostSpeed, ForceMode2D.Impulse); //Add impulse
              }
              else if (direction == 3)
              {
                  rb.AddForce(Vector2.up * boostSpeed, ForceMode2D.Impulse); //Add impulse
              }
              else if (direction == 4)
              {
                  rb.AddForce(Vector2.down * boostSpeed, ForceMode2D.Impulse); //Add impulse
              }
             
          }
      }
     }
 }

I hope i understand it right and helped you in the process