Game Development Reference
In-Depth Information
35.
}
36.
37.
//Check if the camera is far below the character
38.
if(playerPos.y - camPos.y > maxDistanceUp){
39.
camPos.y = playerPos.y - maxDistanceUp;
40.
}
41.
//Check if the camera is far above the character
42.
else if(camPos.y - playerPos.y > maxDistanceDown){
43.
camPos.y = playerPos.y + maxDistanceDown;
44.
}
45.
//Set the position of the camera
46.
transform.position = camPos;
47.
}
48. }
Listing 7: The character tracking mechanism for the camera
Search WWH ::




Custom Search