How do I make rotations of a rigid body affect others touching it? I have a floating rigid body in my world (mass 0) and I have custom keybinds to change the rotation, along each axis. But when I place a different rigid body (with mass of greater than 0) on top of the floating rigid body then rotate it, the floating box visually rotates and goes through the new box. The new box seems to follow collision box of the floating boxes original rotation.
Update: after further testing it kinda works as in the new boxes follow the new collision box if they have been created after rotation, but sometimes it is still a little bit off??
Also, the floating box still visually goes through the new objects.
Are you using Minie or jme3-jbullet? Which version?
Are you using RigidBodyControl? If so, what modes are the controls in: dynamic or kinematic?
Are the boxes added to both the physics space and the scene graph?
…
Based on the limited information, I’m with sgold with my guesses: either you are rotating the spatial and not the body or the 0 mass body is not kinematic.
…given your description, the latter seems most likely.
So uh this might be irrelevant but I managed to not only make it so the game doesn’t run horribly after a few seconds worth of rotating the floating cube but also reduce the lines of code to make the physics rotate to just 1 line! After this I feel so embarrassed…
Before:
RigidBodyControl physics = new RigidBodyControl(0.0f);
rotatable.addControl(physics);
bulletAppState.getPhysicsSpace().remove(rotatable.getControl(0));
bulletAppState.getPhysicsSpace().add(physics);
physics.setKinematic(true);
physics.setPhysicsRotation(rotatable.getLocalRotation());
Issue with this, is that it keeps on adding new instances of the control which pile up and eventually make it so hundreds of controls are attaching to the same box.
Please let me know if this is a wrong, inefficient or sketchy way to achieve my goal, I am only new to jMonkeyEngine so I am not surprised if this too is wrong.
A single-line solution isn’t necessarily better than a multi-line solution, but in this case, it is. However, it’s not the best possible solution.
If you put the RigidBodyControl into kinematic mode, then the physics library should automatically rotate and translate the physics object to match the rotatable:
rigidBodyControl.setKinematic(true);
There’s a whole page about RigidBodyControl in the Minie tutorials, including simple examples: