How do I only add drag on the x axis in unity2D?

I have a player. The movement code is using AddForce. (I need to use AddForce because of other physics in the game, please don’t just tell me to switch to velocity.) I wanted the player to come to an immediate stop. I looked up how to do this, and found I can simply change the linear drag value on the Rigidbody2D. However, doing this also added drag on the Y axis, effectively ruining the player’s jump/gravity. So I was just wondering if anyone knows of a way to only have drag on the X axis. thanks!

I think I’m missing something about not setting velocity, why won’t this do the trick: ?

Vector3 velocity = rigidBody.velocity;
velocity.x = velocity.x / (_xAxisDrag + 1f); // zero = no drag. Start with a small value like 0.05
rigidBody.velocity = velocity;

I suggest you to do a rb2d.velocity = Vector2.zero as soon as the player release the key AND is grounded. To prevent zeroing the velocity even when it’s idle, you can have a bool _isIdle that prevents additional and useless attribution to make the player stop moving.

I hope when you said to not suggest using velocity you were referring to moving the character.