change the view of the player's weapon, behind or in front of

I would like to know how to change the view of the player’s weapon, if the cursor is pointing down the weapon will be in front of the player and if the cursor is pointing up the weapon will be behind the player, like in nuclear throne.


Thanks, I was experimenting to find the result, but your answer was clear and precise.