Godot Version
Godot v4.5
Question
Hi everyone! I’m working on a game right now and am facing an issue with the basic movement engine. Essentially, I want a system where a RigidBody2D can be moved around using another RigidBody2D as a “leg”, with that leg’s extension and direction controlled with the analog stick.
Here’s a basic sketch of what I want to do, where the leg can be used to vault the player forward:
(It’s not unlike that game “Getting Over It”, or its inspiration game “Sexy Hiking” lol)
So here’s my scene setup for the player. (The scene setup for the world is just a simple StaticBody2D. The leg is on a second layer that should also be able to interact with the ground so it doesn’t collide with the main body.)
And here’s the code I’ve written to try to accomplish the effect.
extends RigidBody2D
func physics_process(delta: float) -> void:
var input_vec: Vector2 = Vector2(
Input.get_joy_axis(0, JOY_AXIS_RIGHT_X),
Input.get_joy_axis(0, JOY_AXIS_RIGHT_Y)
)
position = input_vec * 60
rotation = input_vec.angle() + deg_to_rad(90)
And finally, here’s what’s happening when I try it.

As you can see, the leg isn’t interacting with the ground at all. Afterward, I tried a solution where I got rid of the second rigidbody and just attached the code to a CollisionShape2D. (Same code as before, just change extends RigidBody2D to extends CollisionShape2D.) This time, the body part did interact with terrain, but it was janky and unwieldy.

When I tried locking the rotation of the parent node with this setup, I was able to get something less glitchy, but now the body could no longer move and was stuck in place like this.

So, I’m officially stumped here. As I understand it there is some weirdness involved with trying to manipulate a RigidBody’s position/rotation every frame, but I couldn’t figure out a different solution that worked within the constraints of the object type myself.
Through further testing I’ve been able to find that moving a RigidBody through its built-in force functions (impulse, torque, etc) seems to get the body to interact well with the ground, not clipping in like the second gif. But I can’t for the life of me figure out how to make that movement something the player can control in the way I want it to. I think the answer might have something to do with having a target position that the RigidBody always tries to move toward with a constant force? But that’s just a guess, and my tries there haven’t been to successful either.
Does anybody have any ideas? Have I been even a little close with any of my attempts? Please let me know if so!! Thank you so much :]


