Stopping Kinematic RigidBodies with a Static RigidBody

Hi everyone!

I’ve been working on collisions and I’m having some difficulty with it.

I’ve attached a box geometry to a node called ‘playerNode’. I’ve added a RigidBodyControl with a ‘1f’ mass and kinematic mode enabled to the playerNode. I also move the node using ‘setLocalTranslation’. The reason I’ve enabled kinematic mode is that if I use methods like ‘apply force’ then my box object rotates too much and setting the angular factor to ‘0’ moves the object to positions I don’t want.

Even though the movement works fine using the ‘setLocalTranslation’, I still want the object to stop when it hits a static rigidbody. I’ve applied a static rigidbody to another box geometry that acts as a wall. Every time I move my object/player, it goes through the wall. I’ve went into the debug console of JMonkey and it throws out a ‘warning CollisionDispatcher.needsCollision: static-static collision!’

There must be something I’m doing wrong though, any help will be appreciated.

Thanks guys!

The static-static collision warning is probably not worth worrying about.

Have you tried enabling physics debug with physicsSpace.enableDebug(assetManager) ?

1 Like

Hi sgold!

I enabled physics debug. From what I know is that if something is static then the wireframe changes to the blue color. When something is moved (Dynamic Physics) or if something is Kinematic then the wireframe changes to pink. (That is what happened when I changed objects masses or setting them to kinematic when I accessed the debug mode.)

My issue is that when I move my kinematic box, I want it to stop as soon as it hits the wall. The wall is not kinematic but static (zero mass). Do you have any solutions that might solve my problem?

The point of the kinematic mode is that you can place the object so its not supposed to collide with static objects, if it did it would not be placed where you put it.

You could continuously set the velocity of a RigidBody to get collision detection while moving the object somewhat directly or just do a collision rayTest/sweepTest before moving your objects absolutely to determine collisions.

1 Like

Hi Normen!

Ok, even though I’m new to to this, I’ve learned a lot over the past few days. When you meant by ‘continuously set the velocity of RigidBody’, do I then use setLinearVelocity in the physics tick as the movement of the RigidBody? Like I said, I’m new to this.

Or do you recommend that I rather use the rayTest/sweepTest method?

Thanks for the help so far!

Hi Normen!

I finally found a solution. I switched back to a dynamic rigidbody, used setLinearVelocity and set the angular factor to 0 to stop the rotation and everything seems to work fine! Thanks for your and sgold’s help, truly appreciate it!

1 Like