Part 6: Scene Boundaries

Christiane Snyder

Currently, the camera can move through the ground. We’ll fix that by putting bounds on the Y position of the camera, which will ensure both the main camera and the attached character won’t reach the ground plane(and therefore never collide with it) because the camera won’t ever reach a point with a Y value less than -4.0f.

This is easy enough, but remember that the simulation must maintain a constant velocity at all times to avoid causing simulator sickness.

To maintain a uniform speed when the minimum y value is reached, we’ll calculate a temporary forward vector with the same x and z as the camera’s actual forward, but with a y value of 0. This temporary vector will then be normalized, so it will have the same length as the original (length = 1) and therefore allow the objects to continue at the same speed, but in a slightly altered direction. This will prevent these moving objects from continuing downwards even if they are facing that direction.