Stop the RigidBody from rotating freely on PinJoint2D

Godot Version



I want my CharacterBody2D to have a child RigidBody2D that is used as a swingable weapon (in a sledgehammer-like fashion).

I bound the bodies together with a PinJoint2D, and when I apply the torque the RigidBody swings nicely, but when I move my character, the RigidBody rotates - the other end of the Body wants to ‘stay in place’. As a result, I can swing the RigidBody just by moving the CharacterBody - I don’t want that.

I want to rotate (or apply the torque to) the RigidBody only by specific key press. PinJoint2D shouldn’t be able to exert any force onto the RigidBody (or maybe it should, but not just to one point, like it does right now, but rather to whole body simultaneously, so it doesn’t go into rotating motion).

I’m just going to change the weapon type to Area2D and implement the physics myself, I thought that godot’s ready-made physics would make things easier, but considering the game I’m making I think it my own physics will cause less problems down the road. Feel free to leave a solution for other fellow souls, if you find any