(JME3) Boxes move when Applications starts

Hi there!

Just registered here, because I have a little question :wink:

I just started with JME3 and made a little project.

I put 10 boxes (=PhyicsSpaces) on the floor (=another Box an PhysicsSpace). But when the app starts, the boxes start to move around - one of them even falls down the floor and I don’t know why :smiley:

(I have 2 pictures, how can I attach them?)

import com.jme3.app.SimpleBulletApplication;

import com.jme3.bullet.collision.shapes.BoxCollisionShape;

import com.jme3.bullet.nodes.PhysicsNode;

import com.jme3.material.Material;

import com.jme3.math.Vector3f;

import com.jme3.scene.Geometry;

import com.jme3.scene.shape.Box;

import com.jme3.texture.Texture;

public class JMEWindow extends SimpleBulletApplication {

private static final float kubbWidth = 0.035f;

private static final float kubbHeight = 0.075f;

private static final Box kubb = new Box(Vector3f.ZERO, kubbWidth,

kubbHeight, kubbWidth);

private static final BoxCollisionShape kubbCollisionShape = new BoxCollisionShape(

new Vector3f(kubbWidth, kubbHeight, kubbWidth));

Material grass, wood;

PhysicsNode[] kubbs = new PhysicsNode[10];

public JMEWindow() {


private void makeKubb(final int number) {

Geometry kubb_geo = new Geometry("Kubb " + number, kubb);


kubbs[number] = new PhysicsNode(kubb_geo, // geometry

kubbCollisionShape, // collision shape


final int mult = (number/5==0)?1:-1;

kubbs[number].setLocalTranslation(-2.5f + (number % 5) * 1.25f, kubbHeight,








public void simpleInitApp() {

grass = new Material(assetManager,


Texture tex2 = assetManager.loadTexture(“grass.JPG”);

grass.setTexture(“m_ColorMap”, tex2);

wood = new Material(assetManager,


Texture tex = assetManager.loadTexture(“wood.JPG”);

wood.setTexture(“m_ColorMap”, tex);

// mat2.setColor(“m_Color”, ColorRGBA.Red);

Box plane = new Box(Vector3f.ZERO, 2.5f, 0f, 4f);

Geometry floor = new Geometry(“Floor”, plane);

BoxCollisionShape floorShape = new BoxCollisionShape(new Vector3f(2.5f,0f,4f));


PhysicsNode floorNode = new PhysicsNode(floor,floorShape,0);






cam.setLocation(new Vector3f(0f, 0.1f, -4f));

cam.lookAt(Vector3f.ZERO, new Vector3f(0f, 1f, 0f));

for(int i=0;i<10;++i){





public static void main(String[] args) {

JMEWindow app = new JMEWindow();




Your cubes have a 0.5 mass, so they fall, that’s what physics does.

If you want them static set a zero mass when creating them, as you did with the floor.

kubbs[number] = new PhysicsNode(kubb_geo, kubbCollisionShape, 0);

But be aware that the setMass Method seems not to be working properly. In case you want to set the mass later to some non-zero value.

But I want to collide other objects with the boxes later - so they need the mass (I think)

Or should I create them without a mass and change it later?

Here are 2 screenshots:

With mass=0f (static) http://img687.imageshack.us/i/jme1.jpg/

mass=0.5f http://img3.imageshack.us/i/jme2.jpg/

For the floor isn’t at an angle, I wonder why the boxes move to the middle…

Thanks, for your patience :slight_smile:

You should place the cubes directly on the floor. You are placing them at “kubeHeight”.

it should be kubeHeight/2

kubbHeight is actually half the height of the box, because in the constructor you set the size in bothdirections.

So the box should be exactly on the floor:

Image (with mass=0f) http://img704.imageshack.us/img704/4289/jme3.jpg

Has anybody an idea - I cant’t figure out the problem…

Already played with friction or some damping?

Maybe the box “slide” when you launch the application.

Try to set some friction to your boxes ( setFriction()) on the node.