Character follow the camera

How can I do camera follow the node?

I have a character and a scenario. How can I do character follow the camera?

I wrote this methods: cameraNode= new CameraNode ("Camera Node", cam);

input = new NodeHandler(this, cameraNode, "test"); but neither camera, neither character got move…


Have You attached the camNode to the rootNode ?

This is something I struggled with as well and ended up with a solution that may or may not be the best way to go.

For the more seasoned jME developers I think this would be a very good thing to post some best practice code on how to do this as it is not something that is straight-forward.

Here are the items I would like to see addressed if someone is willing to take responsibility to do a simple example:

  - Setting the camera to look through the eyes of the main character

  - Moving the mouse rotates the character and the camera

  - The character is attached to PhysicsWorld and forces applied to the character effect the camera

  - Locking the character node from being able to fall over (this is less related but a problem that I think follows logically in developing a FPS) when forces are applied to it

  - The ability to look up and down with the mouse without the character moving

Perhaps I'm incorrect here, but I believe that these are common problems people are having when trying to develop a FPS with jME and addressing then and perhaps even putting an example in the jME source would be very beneficial.



I'm writing a racer, and for that I needed to be able to have a camera view under the car, and a 'chase' camera behind the car.  I wanted to use a CameraNode, but wound up making my own 'AttachableCameraNode' which allowed the camera to be moved from one node to another (makes billboarding simplel w/ only one camera in the game)

From there it was just a matter of rotating and translating the node, and attaching it to my car's root node (not the games root node)… this allowed it to keep a constant position relative to the car.  You should be able to do something similar by attaching the camera's node to your Character in a FPS or RPG type of game, and get what DarkFrog was looking for (a camera feeling the effects of the physics world/looking through the eyes of a character)

so instead of this scene graph:



CameraNode  Car/Person…

I have this:






It's not exactly what you are looking for but moght be helpful you have cipher through the post and put all together

Hi there,

guys…but now, the camera don

For a car, you control the car the same as you normally would;  an InputHandler takes the keyboard input and controls the car's gas/turning.  I'd imagin that it should work the same for an FPS character.  Use the normal input system, and make sure that the Node it controls contains both the character and the camera.

A first-person perspective on a car or something is quite a bit different actually than an FPS style camera configuration as you want to tie the camera and the character to the mouse movements.  However, you only want moving the mouse left and right to turn the character as up and down should only effect the aiming.  This is one of the most complicated aspects of this style game I believe.  I have functional code that does this, but I'm not sure it's the most efficient way to go.  I'm still looking into how to do this better but I'm sure some of the more seasoned developers here with jME would be more capable of giving an answer.