Thanks for this, Jean!
Can you tell me how to do it to perform the action every frame? This is particularly useful when you have your character colliding with something in one of the axis, so you want to constraint the movement in that particular axis, but still allow movement in the other ones.
Cheers!