The scene contains a positioned terrain so that its center is at (0, 0, 0). The red cube is controlled by the user's arrow keys through the PlayerControl script.
Just as with the previous 2D recipe, a reference to the (3D) RigidBody component is stored when the Awake() method executes, and the maximum and minimum X and Z values are retrieved from the two corner GameObjects and are stored in the x_min, x_max, z_min, and z_max variables. Note that for this basic 3D game, we won't allow any Y-movement, although such movement (and bounding limits by adding a third max-height corner GameObject) can be easily added by extending the code in this recipe.
The KeyboardMovement() method reads the horizontal and vertical input values (which the Unity default settings read from the four directional arrow keys). Based on these left-right and up-down values, the velocity of the cube is updated. The distance it will move depends on the speed variable...