Make your own free website on Tripod.com

3D movement - Part II

In order for the player to move forward, the camera and the camera target must be moved together along the line that they create between themselves. For this to happen, first we must calculate DeltaX and DeltaY, or the difference in X and Y values of the points.
Here, the DeltaX is 10, the DeltaY is 5. From these numbers we can determine the rise and run of the two points. To move the points along in the line that they create, all we have to do is move them 10 units along the X axis, and 5 units along the Y axis.
Unfortunately, that is too big a jump for the game. The player would seem to jump a long distance instantly, and it would be anything but smooth. To fix this problem, we divide DeltaX and DeltaY by 10 (or any number) so that the points only move a fraction of their difference. The result is that the player can move forward regardless of the direction they are facing.
To move backward, the process is simply reversed, DeltaX and DeltaY are subtracted from the current X and Y coordinates.