Rigidbody that is moved with velocity will not move other rigidbodies

Godot Version

4.2

Question

So I have two rigidbodies that are moved with linear velocity and angular velocity, let’s call them hands. So here is the problem for example one of the hands collides with another rigibody in this case a cube, the cube will act like a rock; no matter how big the velocity or the mass is for the hands, the cube will just not move.

linear_velocity = (controller.global_position - global_position) / delta
angular_velocity = (controller.global_basis * global_transform.basis.inverse()).get_euler() / delta

Linear velocity is a managed variable.

Use _integrate_forces as your process loop for precise control of the body state.

Or even better, use forces if you don’t need to set the velocity directly, which you shouldn’t need to.

1 Like

Thanks! I tried to set them in the _intergrate_forces and it worked. I’ll try to make a version where it only uses forces to move, but it will be much more difficult than this.

With some testing with my main project it does not work, tried with setting the velocity but that didn’t work, no surprises there. Then I tried using forces to move the object and even that didn’t work, the cubes just stay in place like a rock.

Well, you can always post your entire project (preferably as a git) if you think that’s worth looking at.

It’s not worth it, thanks for the help tough! I got frustrated and just used move_and_slide() and a characterbody

I figured it out!!! So I had the hands in the layer 7 and mask set to 1, no problems there but all of the cubes where in layer 1 and mask set to only 1. So the boxes didn’t collide with the hands that where in layer 7. I am such a fool!!!

Btw thanks for the tip about using apply_central_forces, that stopped the hands from making weird moves when they are close to physics objects. Also I tried to use apply_torque but I couldn’t get it to work, any tips?

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _physics_process(delta):
	#could use a force to stop them but that would take time this is instant
	linear_velocity = Vector3.ZERO
	apply_central_force((controller.global_position - global_position) / (delta*delta) * mass)
	angular_velocity = (controller.global_basis * global_transform.basis.inverse()).get_euler() / delta

To apply torque you need it to point to the “pole” of the spinning motion. So say you wanted to spin a nut on a bolt, the torque force would be pointing along the bolt’s axis. In 2D, if you’re seeing the XY plane, you probably want to apply torque on the Z axis.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.