Flying with Rigid Bodies

Godot Version

4.5

Question

I have been having issues with my system for picking up and moving rigid bodies. Whenever I try and move my mouse directly under the player the player is picked up by the rigid body and starts to fly away with it.

I have done some research about this, but to my knowledge I can’t find anything on the forums or on reddit about this issue and how to fix it, at least in godot. I’ve tried changing the moving platform behavior of the player, and changing the shape of the players collision, but nothing works.

I am willing to send the code I used for picking up the rigid bodies, but I think this might be more of a physics/setting issue I have yet to solve. I have sent a video showcasing the issue I’m having.

You could set up your collision layers and masks such that picked up objects simply don’t collide with the player. Relevant docs page: Physics introduction — Godot Engine (stable) documentation in English

Thanks for responding, this fixes the issue of flying away from having it under the player, but now it is very easy to push the object through walls by walking into walls while holding it. Is there a way you know to not have this happen?

Games that allow you to pick up objects have to deal with this, the player generates impossible forces. “Prop surfing” is very common, typically a game will detect if the player is standing on the object they have selected and force the player to drop it. The Legend of Zelda Breath of the Wild (and it’s sequel) both force the player to drop items they are standing on, still players can prop surf by stacking two items and grabbing the bottom one.

Yep, you just have to configure the layers such that the held object collides with the environment, but not the player!

One way of doing this:

Layer 1: Environment & objects in general

Layer 2: Player

Layer 3: Held objects

Player collides with layer 1 (so collision mask has only layer 1 enabled on it)

Held objects collide with layer 1 (same as player)

Environment collides with layers 1 & 3 (so, collision mask has 1 and 3 enabled on it!). Might be unnecessary, could be enough that the held object has the environment in the mask and not the other way around, but I don’t see the downside of doing this.

Thanks! This works great, as far as I can tell right now! The rigid bodies are a little jittery when I force them against the wall but that isn’t that big of an issue to me.