Moving a Box and Collision problem

Hello everybody,

I’m new here and it’s my first topic in this forum, here is my problem:

In my game, the main Character is a Box, i want it to move (with arrow Keys) Up, Down, Left, and Right, here is my code :


Box b=new Box(Vector3f.ZERO, 0.6f, 0.6f, 0.6f);

geom1 = new Geometry(“Box”, b);


Material matp = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”); // create a simple material

matp.setColor(“Color”, ColorRGBA.Red); // set color of material to blue

geom1.setMaterial(matp); // set the cube’s material

SphereCollisionShape playerShape = new SphereCollisionShape(0.6f);

player = new CharacterControl(playerShape, 0.01f);




player.setPhysicsLocation(new Vector3f(0, 15f, 1f));




public void simpleUpdate(float tpf) {

Vector3f v = geom1.getLocalTranslation();

if (left) { v.x -= 0.05f; }

if (right) { v.x += 0.05f; }

if (up) { v.z -= 0.05f;}

if (down) { v.z += 0.05f;}

player.setPhysicsLocation(v); // Where i move my player



I tested player.setWalkDirection(v); but the box moves with jumping and i don’t want that. And when i do player.setPhysicsLocation(v); the player don’t detect the collisions with the other shapes.

My question : How can i move my Box correctly (without jumping) and detect collisions?

Thank you for your answers and excuse my wrinting, English is not my native language.

PS : JME Roxx :slight_smile:

ok here’s your problem

while using CharacterControl u should only use

player.setWalkDirection(Vector3f direction)

for walking

i refrence u for the tutiral Hello Collision

Thanks groover for your answer,

I tested player.setWalkDirection(v); but the box moves with jumping and don’t want it to jump while moving