The Camera class is used to define the point of view of the player in the 3D game world. To move the camera during the game simply adjust its Location and Rotation properties. The Camera class works together with the Pawn and PlayerController classes to control its position and effects that occur during the game.
In Unreal Tournament the default camera used is in first person. This camera is simple to define as we just need to get the point of view related to the eyes of the Actor that represents the player. This is done with this function in Pawn class:
GetActorEyesViewPoint( out vector out_Location, out Rotator out_Rotation )
The third-person camera is used in some situations in the game Unreal Tournament, for example when the player enters a vehicle. Setting a third-person camera is much more complex because we must also consider whether there is any obstacle between the camera and the player. The code that calculates the position for this camera is in this function of UTPawn class:
bool CalcThirdPersonCam( float fDeltaTime, out vector out_CamLoc, out rotator out_CamRot, out float out_FOV )
The Camera class has a function called UpdateCamera(float DeltaTime) that is called every frame. This function calls another function DoUpdateCamera(float DeltaTime) which calls UpdateViewTarget(out TViewTarget OutVT, float DeltaTime). The function UpdateViewTarget allows the Pawn class to set the camera position calling its CalcCamera() function in the code snippet below:
//Inside Camera.UpdateViewTarget(out TViewTarget OutVT, float DeltaTime):
TPawn = Pawn(OutVT.Target);
// Give Pawn Viewtarget a chance to dictate the camera position.
// If Pawn doesn't override the camera view, then we proceed with our own defaults
if( TPawn == None || !TPawn.CalcCamera(DeltaTime, OutVT.POV.Location, OutVT.POV.Rotation, OutVT.POV.FOV) )
{
//camera default...
}
The code below is the function CalcCamera of the UTPawn class:
simulated function bool CalcCamera( float fDeltaTime, out vector out_CamLoc, out rotator out_CamRot, out float out_FOV )
{
// Handle the fixed camera
if (bFixedView)
{
out_CamLoc = FixedViewLoc;
out_CamRot = FixedViewRot;
}
else
{
if ( !IsFirstPerson() ) // Handle BehindView
{
CalcThirdPersonCam(fDeltaTime, out_CamLoc, out_CamRot, out_FOV);
}
else
{
// By default, we view through the Pawn's eyes..
GetActorEyesViewPoint( out_CamLoc, out_CamRot );
}
if ( UTWeapon(Weapon) != none)
{
UTWeapon(Weapon).WeaponCalcCamera(fDeltaTime, out_CamLoc, out_CamRot);
}
}
return true;
}
At the end of this code we can see that the function allows the weapon in use to do some adjustment to the camera through the WeaponCalcCamera() function. I looked in the weapons classes of UTDemo that come with the UDK and none implements this function. An example of a weapon that should do this adjustment is the Sniper Rifle in Zoom mode.
For more information about Camera:
Sniper Rifle Zoom in UT2004 |