Moving a RigidBodyControl in the simpleUpdate method


I want to make a enemy that moves from side to side of the screen, i’ve created my enemy with this code:

private void construirNaveEnemiga() {

Box caja = new Box(new Vector3f(0,0,0),3,3,3);

naveEnemiga = new Geometry(“enemigo”, caja);

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

mat1.setColor(“Color”, ColorRGBA.Red);


naveEnemiga.addControl(new RigidBodyControl(0));

naveEnemiga.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(0, 40, 0));





and the movement with this:

private float tiempo = 0;


public void simpleUpdate(float tpf) {


tiempo += tpf*100;

float movimiento = FastMath.sin( FastMath.DEG_TO_RAD * (tiempo % 360) );

naveEnemiga.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(movimiento * 40 * tpf, 0, 0));

//naveEnemiga.move(movimiento * 40 * tpf, 0, 0);


when i use setPhysicsLocation the enemy does not move, and when i call move() in the Spatial, only the spatial moves not the collision box.

thanks for any help.

don’t use physics when you want to move the object manually or set it to kinematic mode. if you use physics you have to use forces to move the objects, else its like beaming them around.

i call setKinematic(true) and now it works,

thanks a lot.