Game Development Reference
In-Depth Information
6.
We generally want to use the rotation of our target, in this case our pawn, so that
we view the world as it would. If that's the case, we'll want to have this turned on.
/** If the camera properties forces the camera to always
use the target rotation, then extract it now */
if (CameraProperties.UseTargetRotation)
{
OutVT.Target.GetActorEyesViewPoint(V,
OutVT.POV.Rotation);
}
//CameraProperties.UseTargetRotation = false;
This is another Boolean, which we can select to have on or off in the
TutorialCameraProperties class.
7.
We will want to offset the rotation of our camera from its default socket location.
This is what allows us to create first, third, and virtually any other camera we'd
like to use. We'll also need to do the applicable math for the calculation.
/** Offset the camera */
OutVT.POV.Rotation+=CameraProperties.CameraRotationOffset;
/** Do the math for the potential camera location */
PotentialCameraLocation=OutVT.POV.Location+
(CameraProperties.CameraOffset>>OutVT.POV.Rotation);
Technical editor William Gaul described the whole process as follows:
Put simply, A >> B rotates vector A in the way described by rotator B. One
Unreal rotation unit is 32,768/Pi radians, however people tend to think
in degrees. For reference, check the following:
F 65,536 = 360 degrees
F 32,768 = 180 degrees
F 16,384 = 90 degrees
F 8,192 = 45 degrees
F 182 = 1 degree
What occurs here is a coordinate system transformation. We take the
local CameraOffset and adjust it to global space so it can be applied
to the out vector.