Bullet Physics: How to keep dynamic rigid body from being pushed?

Hi. I need to make my NPC collided with each other, so I change it’s rigid body from kinematic to dynamic. But now it’s getting hardly pushed by another NPC. Can I prevent it?

I tried to increase the mass, make force and impulse zero

actor_node.set_mass(9999.0) 
actor_bs_np.node().apply_central_force(Vec3(0, 0, 0))
actor_bs_np.node().apply_central_impulse(Vec3(0, 0, 0))
actor_bs_np.node().apply_torque_impulse(Vec3(0, 0, 0))
actor_bs_np.node().set_linear_velocity(Vec3(0, 0, 0))
actor_bs_np.node().set_angular_velocity(Vec3(0, 0, 0))

But nothing is changed :frowning:

Got it worked by putting above code inside the task:

        lin_vec_z = actor_rb_np.node().get_linear_velocity()[2]
        ang_vec_z = actor_rb_np.node().get_angular_velocity()[2]

        # Disabling movement and rotation forces
        actor_rb_np.node().set_linear_velocity(Vec3(0, 0, lin_vec_z))
        actor_rb_np.node().set_angular_velocity(Vec3(0, 0, ang_vec_z))
        actor_rb_np.node().set_angular_factor(Vec3(0, 1, 0))  # disables rotation
        actor_rb_np.node().set_linear_factor(Vec3(1, 0, 1))  # disables rotation

Now NPC stops being hardly pushed and rotated.

I think that you might also have success by setting the rigid-body’s mass to 0–this should result in it being treated as a “static” object, one that things can collide with, but that isn’t moved by collisions, if I recall correctly.

That said, what sort of collisions do you have in mind if you want collisions to occur, but no collision-response to them?

I’m trying to get behavior for capsule (or any other) collider like how it’s done on Unreal Engine, i. e. collider has kinematic behavior (collider doesn’t fall, stays vertically always), but does collision response: just pushes out a bit when collision occurs.

Ah, I see. Fair enough!

In that case I’d suggest just using kinematic objects and then handling the collision response yourself in code.

(Or, if you’re not using the physics side of Bullet at all, then perhaps using Panda’s built-in collision system.)

Above solution mostly works for me… I prefer Bullet because I’m going to add some flying characters to my game (which could be interest side of the Bullet), besides of non-flying characters.

But, yeah, for other case Panda’s built-in collision would be better choice.

Fair enough! If it works, it works.

I am curious, if I may: what do you mean by this? Do you intend some sort of physical simulation of flight?

Yes, of course :slight_smile: I think it will help me to understand Bullet Physics better

Ohhh, I see! Well, have fun in implementing that–it seems like an interesting project! :slight_smile: