AddForce not affecting the X-axis.

I’m completely stumped by this problem. AddForce does nothing to the X-axis…

I’m at my wits end with this problem. I haven’t found anything online that helps. I really really want to implement wall jumps and a Dash to my game. But with no way to alter my horizontal movement, I don’t think that’s possible.

This is everything in my controller that controls horizontal movement. It works just fine for moving

float h = Input.GetAxisRaw("Horizontal");
  
            if (h * GetComponent<Rigidbody2D>().velocity.x < maxSpeed)
                GetComponent<Rigidbody2D>().AddForce(Vector2.right * h * moveForce);
          
  
            if (Mathf.Abs(GetComponent<Rigidbody2D>().velocity.x) > maxSpeed)
                GetComponent<Rigidbody2D>().velocity = new Vector2(Mathf.Sign(GetComponent<Rigidbody2D>().velocity.x) * maxSpeed, GetComponent<Rigidbody2D>().velocity.y);

This example command below will affect my Y Axis if change to (0, 1) but does absolutely nothing to my X axis no matter how ridiculous the Force (like (999999999999, 0)).

if (Input.GetButtonDown("Dash"))
            {
              
                rb.AddForce(new Vector2(9999, 0), ForceMode2D.Impulse);
            }
  • Make sure you are working on the X,Y axis
  • Make sure you don’t have freeze position selected for X axis
  • change the collider on your object to trigger (to see if there is some collision interference that isn’t allowing you to move on the x axis) if there are multiple colliders on your player set them to the same collision layer and set not collide
  • there is probably something i’m overlooking that is a simpler solution but you can try those… (possibly you can’t use add force twice in 1 frame?)