Problem with model not following the attached control [SOLVED]

Hello



I’ve been dealing with an issue for a couple of days, trying to figure it out myself, but find myself short of ideas to solve it.



I create a CharacterControl and a Node , which I attach the control to as such:



[java]private MobControl newMobCharacter(Float width, Float height, Float jumpSpeed, Float gravity, Float fallSpeed, Float stepHeight) {

CapsuleCollisionShape capsule = new CapsuleCollisionShape(width, height);

MobControl characterPhys = new MobControl(capsule, stepHeight, app); //TODO: Mob control to walk towards base

characterPhys.setJumpSpeed(jumpSpeed);

characterPhys.addEventListener(this); //Register for events fired by the control (such as health dropping etc.)

characterPhys.setGravity(gravity);

characterPhys.setFallSpeed(fallSpeed);

return characterPhys;

}



private Node newMobModel(Vector3f loc, Float scale) {

Node characterNode = (Node) app.getAssetManager().loadModel(“Models/Oto/Oto.mesh.xml”);

characterNode.setLocalTranslation(loc);

characterNode.scale(scale);



chaseCam = new ChaseCamera(app.getCamera(), characterNode, app.getInputManager());

chaseCam.setDefaultDistance(chaseCam.getDistanceToTarget() * 1.5f);



return characterNode;

}



public Node initMob(MobType mobType) {

Node characterNode = newMobModel(new Vector3f(0, 150f, 0), 0.4f);

app.getRootNode().attachChild(characterNode);



MobControl characterPhys = newMobCharacter(1f, 2f, 10f, 20f, 55f, 0.05f); //TODO: Get settings from a centralized class

characterNode.setUserData(“Type”, mobType);

characterNode.addControl(characterPhys);



bulletAppState.getPhysicsSpace().add(characterPhys);



chaseCam = new ChaseCamera(app.getCamera(), characterNode, app.getInputManager());

chaseCam.setDefaultDistance(chaseCam.getDistanceToTarget() * 1.5f);



mobCounter++;



mobList.add(characterNode);



return characterNode;

}[/java]

nb: MobControl extends CharacterControl.



Now, the problem is that the physical location of the characterPhys-object actually converges on the target location I want it to end up at, but the camera is stuck on a model that does not move from the very second it is created. The model is stuck in the air (does not fall down).



I’m guessing im missing a link between the node and the charactercontrol.



Anybody able to throw a hint at me ?

I’m using CharacterControl.setWalkDirection(Vector3f dir), if it helps.

I’m using multithreading, so I have a hunch that I have the physics on one thread and the model on another. Could be why they dont move together.

Figured it out. When I extended the CharacterControl I forgot to add super(float tpf) in my MobControl.update(float tpf).

You shouldn’t extend the base classes, use Controls.