This example shows a camera tracking a moving target. You can use the keyboard to move the target being tracked, toggle between different tracking modes, and adjust the tracking offsets.
Compile and run the example
Clone the source code, create a build directory and use
make to compile the code:
To run the example:
There are two main functions in the
Camera class that allow us to track and follow the object:
SetTrackTarget: Set a node for camera to track. The camera will automatically change its orientation to face the target being tracked. If a null node is specified, tracking is disabled. In contrast to
SetFollowTarget the camera does not change its position when tracking is enabled.
SetFollowTarget: Set a node for camera to follow. The camera will automatically update its position to keep itself at the specified offset distance from the target being followed. If a null node is specified, camera follow is disabled. In contrast to
SetTrackTarget, the camera does not change its orientation when following is enabled.