Camera that copies the movement of another camera

I need two cameras (at different positions), one being the main “cam”, to move in a coordinated manner: the secondary camera should copy the rotation of the other. If “cam” moves, the other camera will move keeping the distance between them. I implemented that in a simple way: in the update loop I refresh the secondary camera’s rotation and position. I was wondering if there is another way, possibly avoiding the use of the update loop. I read about CameraNodes but I don’t really know how to accomplish that effect. Thanks!

Well you could write a own class that wraps your camera (like a cameranode), but when you set the first it also sets the second.

Ascii explanations

[java]


| Node | <-just move this node
| |

| camera | | Camera | CameraNodes must have the setControlDirection to SpatialToCamera?
| Node | | Node |

| |
Cam1 Cam2

[/java]


Edit : ....pfff this forum is just not made for ascii art....
2 Likes

Thanks for that! :wink: The problem is that I need to add a functionality to a SimpleApplication. In that class mouse/key inputs move the “cam” camera, and wouldn’t move the Node of your draw directly. If I want to keep the input default behavior, only two ideas come into my mind: reimplementing SimpleApplication (working on intialize() method) or setting cam2’s position in the udpate loop. What do you think?

What I would do would be to write a new class - you pass two camera objects in the constructor. The class has methods like rotate and move, where it just rotates and moves both the cameras by parameters you passed in… Is this not what you need?