How to deactivate translation on collision?

95 Views Asked by At

What I want to do

I want to have my player / character moves simultaneos with an rigid body.
When my character collides with another RB, the other rb shall move - but not my character.

What I want to know

Is it possible to deactivate the translation of a specific rigid body on collisions? If yes, how?

1

There are 1 best solutions below

0
On

RigidBodies in kinematic state are not moved by collision. Anyway they still collide and therefor the other objects move on collision.

You can set the kinematic state as follows:

body.setCollisionFlags(body.getCollisionFlags() | CollisionFlags.CF_KINEMATIC_OBJECT); 

But keep in mind your body won't be moved by ANY physics in your world and you have to set it's position manually via the MotionState.

(Or if you want to move the player by appending forces, you can try to work around by setting a very high mass to the player and use according forces for movement to minimize the impact on your player. I don't know of any clean solution for that.)