How to disable entity's degree of freedom

Hi, is there any way to disable the movement of certain degree of freedom of an entity. That is, one can move an entity on X direction by physics gun but he can never move it on the others, or one can only rotate it on spin direction but can not move it by physics gun.

Is there such kind of functions to restrain the degree of freedom of an entity that the physics gun can not lead, but some other dofs are available.

Thank you!