Hello everybody, i'am here again asking for help, how i can fix the camera? for example, the character will move and camera too, but the player cant change the camera rotation distance etc…
thanks
I would just check the distance between the player and the camera, and if it's longer/shorter than a certain distance, move the camera closer/further away
e.g.
float dist = player.getDistTo(cam.getLocation());
if (dist != 10) { // Example dist
Vector3f dir = cam.getLocation().subtract(player.getLocalTranslation()).normalize();
dir.multLocal(CAM_SPEED * interpolation); // use values to adjust speed the cam will move
cam.getLocation().addLocal(dir);
cam.update();
}
I haven't actually run this, but you get the idea. And just use camera.lookAt() to make sure it's always looking at the player.
you can attach the camera to a player node by using a CameraNode.
You can apply a localTranslation to the CameraNode to get a offset from the player.
see jmetest/renderer/TestCameraMan.java for example.
hammm , thanks, i have another question, how i can put the camera to firstperson like counter strike?
i don't understand the testfirstperson class.