Hi, sorry I’m a beginner with jmonkey, and I’m trying to use BetterCharacterControl to control the position of a node, but by attaching the control to the Node the node doesn’t move with warp or even with physics, question: suggestions? How can I use BCC? Where can I read more? Does it synchronize the position of the spatial it is tied to by itself?
here is my code, thanks in advance!
package com.mygame;
//import list
/
* This is the Main Class of your Game. You should only do initialization here.
* Move your Logic into AppStates or Controls
* @author normenhansen
*/
public class Main extends SimpleApplication {
private BulletAppState bulletAppState;
public static void main(String[] args) {
Main app = new Main();
AppSettings settings = new AppSettings(true);
settings.setResolution(1920,1080);
app.setSettings(settings);
app.start();
}
BetterCharacterControl pControl;
Node playerNode;
private void tryBetter() {
playerNode = new Node();
rootNode.attachChild(playerNode);
pControl = new BetterCharacterControl(2f,6f,1f);
pControl.setGravity(new Vector3f(0f,-9f,0f));
playerNode.addControl(pControl);
bulletAppState.getPhysicsSpace().add(pControl);
pControl.warp(new Vector3f(0f,40f,0f));
System.out.println(playerNode.getLocalTranslation());
System.out.println(pControl.getRigidBody().getPhysicsLocation());
}
@Override
public void simpleInitApp() {
/ Load a Node from a .j3o file */
String userHome = System.getProperty("user.home");
BinaryImporter importer = BinaryImporter.getInstance();
importer.setAssetManager(assetManager);
File file = new File("assets\\Scenes\\scena1\\TestScene.j3o");
try {
Node loadedNode = (Node)importer.load(file);
loadedNode.setName("loaded node");
rootNode.attachChild(loadedNode);
} catch (IOException ex) {
System.out.println(ex);
//Logger.getLogger(Main.class.getName()).log(Level.SEVERE, "No saved node loaded.", ex);
}
/** A white ambient light source. */
AmbientLight ambient = new AmbientLight();
ambient.setColor(ColorRGBA.White);
//rootNode.addLight(ambient);
flyCam.setMoveSpeed(7);
//fisica
this.bulletAppState = new BulletAppState();
stateManager.attach(bulletAppState);
tryBetter();
}
@Override
public void simpleUpdate(float tpf) {
//TODO: add update code
}
@Override
public void simpleRender(RenderManager rm) {
//TODO: add render code
}
}