Game Development Reference
In-Depth Information
bugLog , we can make catching bugs much easier by looking at the console.
This is shown in the following code:
if (trackObj) {
}
else {
Debug.Log("GameCamera:Error,trackObj
invalid");
}
7. Step 2 of our algorithm is to store the desired rotation and height in two local
float variables. In the case of the height, we offset the height of trackObj
by an exposed global variable height so that we can adjust the specifics of
the object as shown in the following code (sometimes an object may have
its transform 0 at the ground plane, which would not look pleasing, we need
numbers to tweak):
DesiredRotationAngle =
trackObj.transform.eulerAngles.y;
DesiredHeight =
trackObj.transform.position.y + height;
8. We also need to store the local variants of the preceding code for processing
in our algorithm. Note the simplified but similar code compared to the code
in the previous step. Remember that the this pointer is implied if we don't
explicitly place it in front of a component (such as transform ):
float RotAngle = transform.eulerAngles.y;
float Height = transform.position.y;
9. Step 3 of our algorithm is where we do the actual LERP ( linear interpola-
tion ) of the current and destination values for y-axis rotation and height. Re-
member that making use of the LERP method between two values means
having to calculate a series of new values between the start and end that dif-
fers between one another by a constant amount.
Remember that Euler angles are the rotation about the cardinal axes, and
Euler y indicates the horizontal angle of the object. Since these values
Search WWH ::




Custom Search