Game Development Reference
In-Depth Information
Illustration 21: The cylinder object used to create the first person input system
Notice that the camera is added as a child to the cylinder and it resides at the top of the
cylinder upper surface. The mouse look mechanism is going to be as follows: when the
player moves the mouse horizontally, we rotate the cylinder around the y axis leading to
right or left rotation of the cylinder, depending on the direction of horizontal displacement
of the mouse. On the other hand, when the player moves the mouse vertically, only the cam-
era will be turned towards up or down. This means that we have two independent axes for
horizontal and vertical rotations, which leads to a system similar to the tripod of the photo-
graphy camera.
Regarding the movement, pressing W key moves the character forward in the direction
the player currently faces (i.e. positive direction of the local z axis of the cylinder object). Sim-
ilarly, pressing S key moves the character in the opposite of the direction it faces. This also
applies to strafing right and left, where pressing D will move the character in the positive
Search WWH ::




Custom Search