Weird Physics Effects

Here’s the code I have so far.

[java]public class Main extends SimpleApplication {

private BulletAppState bulletAppState;

private RigidBodyControl hover_phy;

private RigidBodyControl floor_phy;

public static void main(String[] args) {

Main app = new Main();




public void simpleInitApp() {

bulletAppState = new BulletAppState();


initHoverBox(new Vector3f(0f,5f,0f));




public void simpleUpdate(float tpf) {

//TODO: add update code


public void initHoverBox(Vector3f startpt){

Box b = new Box(startpt, 1, 1, 1);

Geometry geom = new Geometry(“Cab”, b);


Material mat = new Material(assetManager, “Common/MatDefs/Misc/SolidColor.j3md”);

mat.setColor(“m_Color”, ColorRGBA.Blue);



hover_phy = new RigidBodyControl(2f);



hover_phy.setGravity(new Vector3f(0f,0.1f,0f));


public void initFloor() {

Box floorBox = new Box(Vector3f.ZERO, 10f, 0.1f, 5f);

//floorBox.scaleTextureCoordinates(new Vector2f(3, 6));

Geometry floor_geo = new Geometry(“floor”, floorBox);

Material mat = new Material(assetManager, “Common/MatDefs/Misc/SolidColor.j3md”);

mat.setColor(“m_Color”, ColorRGBA.Red);


floor_geo.setLocalTranslation(0, -0.1f, 0);


/* Make the floor physical with mass 0.0f! */

floor_phy = new RigidBodyControl(0.0f);





What happens is that if I set the gravity to (0f,0f,0f), the box goes straight up. If set to (0f,0.1f,0f), it goes up at an agle in a corkscrew pattern. All I want to do for now is have a hovering cube. What am I missing?

Let me see. First off I don’t think you need to updateModelBound, but I could be wrong.

Second, if you want your floor to stay still I recommend floor_phy.setKinematic(true).

As for the upward box, could it be that either you have (0f,0.1f,0f) for the gravity which means positive Y or UP,

OR could it be that your floor is actually falling and the box is staying still?

The only way the camera is moved is to look up. The floor is staying in one place and box is moving in the odd pattern. And now that I removed the gravity portion to under geom.addControl(hover_phy);, the box falls but acts as if it hit an invisible box above the floor. Just adding another issue.

I guess you spawn both intersecting, so the collision stuff applys a large force to push the box out of the floor.

I should have said it differently. It falls but before hitting the floor object it acts as if it hits another object and tumbles towards the camera. I look from a different side and the box isn’t resting on the floor object, but is resting in space as if it did.

Had this happen to me, it’s the floor_geo.setLocalTranslation(0, -0.1f, 0);

Not sure why it happens though, you’d think it wouldn’t if you used setTranslation() before adding the control…

Just a sidenode, 0.1 is far to small for the floor actually, I recommend larger sizes to reduce physic gliches.