Moving a cube with global coordinates

Hello Community,

[java]

// Position is a Vector3f(10, 0, -100);

Box b = new Box(position, w/2, h/2, 0);

geom = new Geometry(“PlayerShape_”+id, b);

Material mat = new Material(parent.getAssetManager(), “Common/MatDefs/Misc/Unshaded.j3md”);

mat.setColor(“Color”, ColorRGBA.White);

geom.setMaterial(mat);

matchNode.attachChild(geom);

[/java]

I think I have just a beginner-problem :slight_smile: After I created the cube this way I want to move him to other coordinates with my position-vector. This means position gets an new value and then I need something like geom.setCenter(position); I’m sorry but I can’t find a suitable method for this.

Thank you for your help and sorry for my bad English (currently I’m learning this language)



Greets Mike

I am not sure what you want, but you can look at this if you haven’t: https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:beginner:hello_node So if you wanna position something, that is called a translation.

by my-position vector do you mean position of the player ? if so you would have to setLocalTranslation of the box in the update loop

Ahh ok, thanks I get it