Game Development Reference
In-Depth Information
55.
if((ang < 0 && ang + currentRotation > -maxVerticalAngle) ||
56.
(ang > 0 && ang + currentRotation < maxVerticalAngle)){
57.
camera.RotateAround(camera.right, ang);
58.
}
59.
60.
//Update last mouse position for next frame
61.
lastMousePosition = Input.mousePosition;
62.
63.
if(Input.GetKey(KeyCode.A)){
64.
character.StrafeLeft();
65.
} else if(Input.GetKey(KeyCode.D)){
66.
character.StrafeRight();
67.
}
68.
69.
if(Input.GetKey(KeyCode.W)){
70.
character.WalkForward();
71.
} else if(Input.GetKey(KeyCode.S)){
72.
character.WalkBackwards();
73.
}
74.
75.
if(Input.GetKeyDown(KeyCode.Space)){
76.
character.Jump();
77.
}
78.
}
79.}
Listing 48: A script to read user input and control the physics character
Search WWH ::




Custom Search