Rigidbody 2D mass doesn't matter?

Godot Version



I need to push a box around. The box is a RigidBody2D, it’s on it’s own collision layer and the player is doesn’t mask that layer.

The player has this script to apply force to the box when colliding with it:

	# after calling move_and_slide()
	for i in parent.get_slide_collision_count():
		var c = parent.get_slide_collision(i)
		if c.get_collider() is RigidBody2D:
			c.get_collider().apply_central_impulse(-c.get_normal() * push_force)

This all works as it should. But no matter how much mass I give the box or how little push_force to the player, the box gets pushed along like it’s an empty cardboard box. A mass of 10KG and a mass of 1000KG have exactly the same effect.

What am I missing?

I’m not sure a Rigidbody mass is considered if a CharacterBody pushes it. It is only considered when being pushed by another Rigidbody2d. I’ve not tested it, I’ve just always assumed that is the case since a CharacterBody has no mass.

1 Like

The character body doesn’t directly push the Rigidbody 2d, it checks for a collision with it and then calls apply_central_impulse on the Rigidbody 2d. So that shouldn’t be an issue.

Disabled the code and I still get the same result. So it looks to be something else going on.

Got the layers mixed up…

1 Like

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