I have an issue with my reloading animation, which was done in blender and imported and converted to a j3o. The animation is working perfectly, but the only problem is that the magazine disappears when I start the program, and only at certain angles it appears. It kinda gets rid of the purpose, so I need to fix the issue, but I don’t know how.
I think I have to call player.updateModelBounds BUT I don’t know where and how to do it right.
P.S: player is a Node
@Override
public void simpleInitApp() {
ScreenshotAppState screenShotState = new ScreenshotAppState();
player = (Node) assetManager.loadModel("Models/reload.j3o");
player.setLocalScale(1);
rootNode.attachChild(player);
Node terrain = (Node) assetManager.loadModel("Models/newScene.j3o");
terrain.setLocalScale(1);
rootNode.attachChild(terrain);
flyCam.setMoveSpeed(50);
control = player.getChild("Cube").getControl(AnimControl.class);
control.addListener(this);
channel = control.createChannel();
channel.setAnim("reload");
if (!channel.getAnimationName().equals("reload")){
channel.setAnim("reload", 0.50f);
channel.setLoopMode(LoopMode.Loop);
channel.setSpeed(1f);
}
}
public void simpleUpdate(float tpf) {
Vector3f vectorDifference = new
Vector3f(cam.getLocation().subtract(player.getWorldTranslation()));
player.setLocalTranslation(vectorDifference.addLocal(player.getLocalTranslation()));
Quaternion worldDiff = new
Quaternion(cam.getRotation().mult(player.getWorldRotation().inverse()));
player.setLocalRotation(worldDiff.multLocal(player.getLocalRotation()));
//Move gun to the bottom right of the screen
player.move(cam.getDirection().mult(17f));
player.move(cam.getUp().mult(-5f));
player.move(cam.getLeft().mult(-3f));
player.rotate(0.0f,0,0);
}