I have a space game with a ship model attached to a node, I also have a camera node with that node attached it it, this seems fine but it seems the actual camera falls behind the camera node/shop model because when I move the camera node, the camera itself does some smooth transition between where the ship is and where it has just moved from.
I know on chasecam you can use something like ‘setMinDistance’ and setMaxDistance’ but I can’t see anything like this on CameraNode or the CameraControl.
This is my code for setting up the camera…
[java]// setup physics
bulletAppState = new BulletAppState();
stateManager.attach(bulletAppState);
bulletAppState.getPhysicsSpace().setGravity(Vector3f.ZERO);
// Setup player
Spatial model = assetManager.loadModel("Models/HoverTank/Tank2.mesh.xml");
CollisionShape colShape = CollisionShapeFactory.createDynamicMeshShape(model);
model.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
ship = new Node("Player");
ship.attachChild(model);
// setup camera and camera node
CameraControl cameraControl = new CameraControl(cam, ControlDirection.SpatialToCamera);
cameraNodePhysicsControl = new RigidBodyControl(colShape, 1f);
cameraNodePhysicsControl.setAngularFactor(0);
cameraNodePhysicsControl.setLinearDamping(0.2f);
cameraNodePhysicsControl.setAngularDamping(0.8f);
cameraNode = new CameraNode("Camera", cameraControl);
cameraNode.setLocalTranslation(new Vector3f(-50000f, 0f, 150000f));
cameraNode.rotate(0, FastMath.PI, 0);
cameraNode.addControl(cameraNodePhysicsControl);
cameraNode.attachChild(ship);
rootNode.attachChild(cameraNode);
bulletAppState.getPhysicsSpace().add(cameraNode);[/java]
What am I doing wrong or haven’t done that I need to do to fix this? I’ve spend hours trying different ways of attaching the ship node to the camera node in the hope it would change the outcome.
Thanks in advance, I really appreciate the help!