[SOLVED]reparent camera to a mover keeping camera heading??

I have an object moving over a 2D map and I want the camera to follow him, watching him from up (+z)

I have set the camera PosHpr to be (moverx, movery, moverz + 200, 0, -90, 0) and then reparent it to the mover. The problem is that when the mover change his heading, the camera do it to, so the mover is always looking to te top of the screen.

I have also tryed to add a task that keeps updating the camera position to the mover position, but when it gets some speed, everything starts to tremble.

How can I make it?

Best solution:

(1) Parent the mover and the camera to a common node. Move that common node around to move both the mover and the camera. Rotate the mover directly (but not the common node) when you want to change the mover’s heading. This way your camera shares its position with the mover, but not the heading.

Not-as-good solutions:

(2) Use a task as you describe to set the camera to the mover’s position each frame. Use sort = 45 on the taskMgr.addTask() function call to ensure that the task happens just before rendering, which will avoid the shaking you describe. This is a fine solution, actually.

(3) Parent the camera to the mover as you say, but put a compass effect on the camera so that it always keeps the same heading regardless of the mover, e.g.:

camera.setAttrib(CompassEffect.make(render))

This will cause trouble if you want to rotate the camera later, but it will be a quick-and-dirty way to avoid inheriting the mover’s rotation.

(4) Instead of parenting the camera to the mover, use a compass effect to keep the camera’s position (but not its rotation) aligned to the mover’s position. This should work, but it’s not recommended just because it’s so weird.

camera.setAttrib(CompassEffect.make(mover, CompassEffect.PPos))

David

I have used the first option and it works perfecly.
Maybe I will test the second one later to avoid having all those nodes and make the program simpler.

Thanks