1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
function UpdateViewTarget(out TViewTarget OutVT, float DeltaTime)
{
local vector CamX, CamY, CamZ;
local MLFPawn MP;
MP = MLFPawn(OutVT.Target);
if(MP != none && !MP.bSprinting)
GoToState('Rest');
if(MP != none && MP.bHardAim)
GoToState('HardAim');
//Make sure the target is a pawn
if(MP != none)
{
//Set the Camera rotation to the Player Rotation for a Fixed POV
OutVT.POV.Rotation = PCOwner.Rotation;
/*Pass in the Camera Rotation to get 3 vectors to help calculate the desired offset*/
GetAxes(OutVT.POV.Rotation, CamX, CamY, CamZ);
//Grab the current camera location
CurrCamLoc = OutVT.POV.Location;
//Calculated the desired camera location from the targets location
DesiredCamLoc = OutVT.Target.Location - CamX*SprintOffset.X
+ SprintOffset.Y * CamY
+ SprintOffset.Z * CamZ;
/*This is the problem location, this function returns a vector that is a certain amount closer to the DesiredCamLoc, but it also causes the camera's position to change dramatically if the player is rotating fast*/
OutVT.POV.Location = VInterpTo(CurrCamLoc, DesiredCamLoc, DeltaTime, 15);
//Make sure we can see the player mesh
MP.RemoveMeshVisibility(false);
//Check the camera collision, make sure we don't get stuck in the model
CheckCameraCollision(MP, OutVT, CurrCamLoc);
}
else
{
/*If for whatever reason the view target is not my pawn class, call the function up the chain to calculate the viewtarget*/
super.UpdateViewTarget(OutVT, DeltaTime);
}
}
|