Godot Version
4.5
Question
Hi everybody! I’ve been working on a movement engine for a game. The basic idea is that you use the two analog sticks on the controller to move a character’s two hands, and you use those hands to vault off the environment and move around.
After some testing and help from forum users, I managed to get a version of this system partially working! I’ll include my project files so you can download them yourself and play around with them. As you can see, the character can use its two little appendages to move around. (Sorry the GIFs are so slow and blurry… I hope you get what’s happening in them…)

Of course, you’ve probably noticed it looks super janky. As far as I can tell, there are two big problems contributing to this:
Problem #1: Loose PinJoint2D
Here’s how the character and its “hands” are connected to each other. It’s just a RigidBody2D connected to two smaller RigidBody2D’s via their respective PinJoint2Ds.
The problem here is that the connection between the center body and its hands is very loose. The hands go wobbling all over the place, and when the sticks are let go, they sag downward instead of just returning to a neutral position:

That’s not me moving the sticks like that, they’re actually that loose. (Again, you can play around with this if you download the project.) I’ve found these problems can be minimized by reducing the space between the hands and their PinJoints, but I’d like to keep them around this length or further from the body if possible, so I’d like to find a solution that will have them perfectly respond to stick input without wobbly physics and return to their neutral resting positions (shown in the editor screenshot above) when there’s no input.
Problem #2: Hands Rotate Toward Desired Position
This is the big one I haven’t been able to fix in any way. When a direction on the stick is pressed, the hand doesn’t just snap to that direction: in order to work with it being a RigidBody2D, it needs to rotate toward the desired direction. Here’s how this works in code for the left hand. (Huge thanks to another user, hyvernox, for this solution!)
extends RigidBody2D
@export var max_extension_length := 50.0
@onready var leg := $CollisionShape2D
var cangrab = false #ignore this! this is for a mechanic i'll add later!
func _physics_process(_delta: float) -> void:
var input_direction := Input.get_vector("left_left", "left_right", "left_up", "left_down")
leg.position.y = max_extension_length * input_direction.length()
func _integrate_forces(_state: PhysicsDirectBodyState2D) -> void:
var input_direction := Input.get_vector("left_left", "left_right", "left_up", "left_down")
var leg_direction :Vector2 = leg.global_position - global_position
var angle = leg_direction.angle_to(input_direction)
angular_velocity = angle / get_physics_process_delta_time()
The issue with this system is that, well, the hand has to rotate all the way around the body from its last position to get to the desired one. This creates undesired effects, where the limb will throw the player in unintended directions or just look a bit strange when the stick is moved in opposite directions:

A more manual approach to moving the hand according to the stick is difficult, since RigidBody objects don’t tend to like it when they’re moved without their built-in force functions. (Take a look at my previous post about this project to see what happens when you try to do it the other way.) I could see a solution where the direction the hand faces is forced to be the input direction upon input, but I don’t want to suggest much before someone smarter than me who knows what they’re talking about gives their opinion.
So what does everyone think? How could I go about solving these issues? If you’d like to try your hand at solving them yourself, you can download the current version of the project and all its code here. Make sure you have collision shapes made visible so you can see anything! Sorry to keep shoving it in your face, but these issues are hard to really convey without feeling them yourself.
I’m open to any suggestions, and I’ll keep looking for solutions on my own too, so I’ll update you if anything works! Please let me know if you have any other questions, and thank you so much for reading! ^^
