0 votes

I have some RigidBody objects I would like to be able to pick up and carry. I still want them to have physics and not go through walls and stuff, and not feel so stiff like when I just parent them to the player. How should I do this? Rotation doesn't really matter.

in Engine by (616 points)

I don't really know and I've never tried that before but I would start experimenting with the following:
get the global coordinates of the camera's local position+50 in the z axis, let's call that position "targetposition". get the objects global position. use the get directionto() function to get a vector that points from the objects global position to the target position. from the object move and slide towards the direction_to value you just go, so something like...


I can't use move_and_slide, this is all in 3D (Spatial) and it's a RigidBody...

1 Answer

0 votes
Best answer

I got it working! I figured maybe someone else could use this too if they want to do it this way.
I used a PinJoint on the Player and I have it dynamically set the node_b to an object when I pick it up, as well as disabling sleeping (otherwise I have to collide with it to wake it up every time) and changing the position to the center of the joint to make sure it's not just swinging around. It works surprisingly well and collisions with other objects work well.

by (616 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.