Make your own free website on Tripod.com

3D movement - Part I
The ability to move in the 3D scene is provided by the camera, and the camera target.
Here the camera is in red, the camera target in blue. The camera will always point towards the camera target. In order to maintain perspective, the camera target and camera need to stay the same distance from each other.
The player will be able to move vertically in the game, using jump jets. To simulate this effect, (as well as gravity) we will alter the Z coordinates of both the camera and camera target.
The Z axis of the 3D world is vertical, but in the above picture, it projects out of the screen. Perhaps this is a better picture:
The X and Y axis are blue and red, while the Z axis is in green. To make the player seem to fly up and fall down, they are moved along the Z axis. This is done by altering the camera target and camera Z position like this:

If player is pressing jump jet key:
CameraTarget Z = Camera Target Z + 1
Camera Z = Camera Z + 1

If player is not pressing jump jet key and player is higher than the ground:
CameraTarget Z = Camera Target Z - 1
Camera Z = Camera Z - 1