Move model inside control

characterModel = (Spatial)assetManager.loadModel("Models/player.j3o");
characterModel.move(new Vector3f(10.0f,10.0f,10.0f));

characterModel.setLocalTranslation(3.0f, 3.0f, 3.0f);

characterModel.rotate(5.0f, 5.0f, 5.0f);


How to move model inside control? Current code not work.

characterModel.setLocalTranslation(3.0f, 3.0f, 3.0f);

characterModel.rotate(5.0f, 5.0f, 5.0f);

I need down model. And move to center of capsule.

And how rotate model with mouse Z coordinates like counter strike? ( camera - vector, rotate - Degrees).

The code you supplied isn’t the code of the control (player?).

You must move/rotate it inside your control’s void controlUpdate(float) method in player. You have more information in the wiki.


player = new PlayerControl(capsuleShape, 0.05f);

//player   = new PlayerControl(capsuleShape,0.05f);



//player.setPhysicsLocation(new Vector3f( 0.9f,  0.02f, 0.22f));

characterModel = (Spatial)assetManager.loadModel("Models/player.j3o");
characterModel.move(-10.0f, -10.0f, -10.0f);



Custom class

public class PlayerControl extends CharacterControl{

PlayerControl(CapsuleCollisionShape capsuleShape, float f) {

public void setSpatial(Spatial spatial) {

public void update(float tpf){

if(spatial != null) {
    spatial.rotate(0, 0, 1.0f);


not work…

SetViewDirection or Wiki (Hello Physics)

Yes, wiki, wiki, wiki, wiki, wiki, wiki, wiki, wiki, wiki, wiki, wiki, wiki, wiki, wiki, wiki, wiki, wiki, wiki, wiki, wiki …

And maybe better to start using JME 3.1 instead of 3.0. Especially if you are just starting out. It doesn’t fix this, but it sure as hell is nicer and newer :slight_smile:

Have this:

  float cX = player.getPhysicsLocation().x;
    float cY = player.getPhysicsLocation().y;
    float cZ = player.getPhysicsLocation().z;
    float mX = characterModel.getWorldTranslation().x;
    float mY = characterModel.getWorldTranslation().y;
    float mZ = characterModel.getWorldTranslation().z;
    float difX = cX - mX; 
    float difY = cY - mY; 
    float difZ = cZ - mZ; 
    characterModel.move(difX, difY- 2, difZ+2);

I think need write custom methods for synchronize capsule and model.

Again, please go through the tutorials. Everything is explained there. Just read and learn. This what you want to do is actually much easier to implement when you read the relevant wiki entries.

Thanks re-read manual. And next my “invention” :slight_smile:

          camOld        = cam.getLeft(); 
         Quaternion camRotation = new Quaternion();
          camRotation.set(-0.173f, cam.getRotation().getY(), cam.getRotation().getZ(), 0.9830f);
          characterModel.setLocalRotation(camRotation); }

Any time you are calling set() on a Quaternion then you are probably doing something wrong.

Usually this is a sign of a barely noob Java developer who doesn’t know where the javadoc is. Hopefully you know where the javadoc is.

Yes, Thank’s
This is test code, i rewrite. Thank’s.