Is there a way to stop a rigidbody from moving in a specific direction?

The way I would usually do it is by setting
rigid.velocity = new vector3
and then zeroing out one of the directions I don’t want the object to be able to continue in, but since the direction can be variable, I’m having trouble figuring out a way of doing this.

I started down this path after I had rigidbodies interacting in ways I didn’t want, so I’m essentially forcing hovering to make sure they don’t touch and so, don’t interact. So I’m pursuing this for now.

Yes, these are the constraints. You can set them via inspector, or by code.

rigidbody.constraints = RigidbodyConstraints.FreezePositionX;

Use bitwise operands to combine contraints, if you wanted to freeze the X and Y you would use

rigidbody.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionY;