Using addforce to throw my character in the x-axis.

EDIT: Found the problem.

Hi guys,

I’m following a tutorial to make a simple platformer. Now in the tutorial we’ve made the character and an object.
If the character touches the object, he get’s thrown in the air (y-axis only).
I’ve tried to change the x-axis expecting the character would’ve get thrown to the left or right also.
But unfortunately the character keeps getting thrown in the y-axis only.

  void pushBack(Transform pushedObject)
  {
  Vector2 pushDirection = new Vector2(0, 1).normalized; // I changed the x value to 1 aswell.
  pushDirection *= pushBackForce;
  Rigidbody2D pushRB = pushedObject.gameObject.GetComponent<Rigidbody2D>();
  pushRB.velocity = Vector2.zero;
  pushRB.AddForce(pushDirection, ForceMode2D.Impulse);
  }

Can someone tell me what I’m doing wrong?

I know I’m 2 years late on this, but I came across this post because I ran into the same problem. There was a thread here which actually had a functional solution. You need to uncheck Apply Root Motion on the object’s Animator component. For some reason, this causes weird locking on some, but not all, axes even if there is no parent object in the hierarchy. Hopefully this helps any other lost souls who find themselves here years in the future.