Code:
// Camera Vars //
var () float CameraOffsetLength;
var float CurrentCameraDistance, CurrentCameraOffsetLength;
// The array of items that we will refer as the inventory //
var () array<SeqVar_MyInventoryItem> PlayerCustomInventory;
function AddItem(SeqAct_AddToMyPlayerInventory MyAction)
{
// Lets create a new inventory item to hold the values passed //
local SeqVar_MyInventoryItem ItemBuffer;
// Instantiate it //
ItemBuffer = new class'Silencer.SeqVar_MyInventoryItem';
// And fill with the information passed //
ItemBuffer.ItemID = MyAction.ItemID;
ItemBuffer.ItemName = MyAction.ItemName;
// And finaly, insert it into the array of itens //
PlayerCustomInventory.AddItem(ItemBuffer);
};
/*********************************************************************************************
Camera related properties
********************************************************************************************* */
simulated function bool CalcCamera(float fDeltaTime, out vector out_CamLoc, out rotator out_CamRot, out float out_FOV)
{
local vector CamStart, FirstHitLocation, HitLocation, HitNormal, CamDir, X, Y, Z;
local float DesiredCameraZOffset;
local bool bInsideHero, bObstructed;
local float DesiredCameraDistance;
local float CameraOffsetRatio;
local vector tempCamStart, tempCamEnd;
local Vector VectorX, VectorY, VectorZ;
bObstructed = false;
//Mesh.SetOwnerNoSee(false);
// Handle the fixed camera
if (bFixedView)
{
out_CamLoc = FixedViewLoc;
out_CamRot = FixedViewRot;
}
ModifyRotForDebugFreeCam(out_CamRot);
CamStart = Location;
DesiredCameraZOffset = (Health > 0) ? GetCollisionRadius() * 0.75 : 0.f;
CameraZOffset = (fDeltaTime < 0.2) ? DesiredCameraZOffset * 5 * fDeltaTime + (1 - 5*fDeltaTime) * CameraZOffset : DesiredCameraZOffset;
CamStart.Z += CameraZOffset;
GetAxes(out_CamRot, X, Y, Z);
/*VectorX here you can implement camera zoom in/out or scaling or whatever you want to call it */
VectorX = X * GetCollisionRadius() * 4.2; //this vector determine depth of camera, how far from character it will be
VectorY = Y * GetCollisionRadius() * -1.9f; // this vector determine side of camera, negative value pull character to left side, while positive to right side
VectorZ = (GetCollisionRadius() /* FMax(0,(1.0-CamRotZ.Z))*/ * Z) * -1.55; //this value try to pull camera forward while pitching down, and back while pitching up, but pulling back seems to dont work
CamDir = VectorX + VectorY + VectorZ;
if ( (Health <= 0) || bFeigningDeath )
{
// adjust camera position to make sure it's not clipping into world
// @todo fixmesteve. Note that you can still get clipping if FindSpot fails (happens rarely)
FindSpot(GetCollisionExtent(),CamStart);
}
/*
if (CurrentCameraScale < CameraScale)
{
CurrentCameraScale = FMin(CameraScale, CurrentCameraScale + 2 * FMax(CameraScale - CurrentCameraScale, 0.1)*fDeltaTime);
}
else if (CurrentCameraScale > CameraScale)
{
CurrentCameraScale = FMax(CameraScale, CurrentCameraScale - 2 * FMax(CameraScale - CurrentCameraScale, 0.1)*fDeltaTime);
}*/
if (CamDir.Z <= GetCollisionHeight())
{
CamDir *= square(cos(out_CamRot.Pitch * 0.00000258738)); // 0.0000258738 = 2*PI/65536
}
out_CamLoc = CamStart - CamDir;
if (Trace(HitLocation, HitNormal, out_CamLoc, CamStart, false, vect(12,12,12)) != None)
{
out_CamLoc = HitLocation;
bObstructed = true;
}
/* This code is from ActionGam, thanks for fall, for creating this.
* It will determine back trace collision while closing to walls or sth like thaht*/
if (Trace(HitLocation, HitNormal, out_CamLoc, CamStart, false, vect(12,12,12),,TRACEFLAG_Blocking) != None)
{
DesiredCameraDistance = VSize(HitLocation-CamStart);
CurrentCameraDistance = (fDeltaTime < 0.5f) ? FClamp(DesiredCameraDistance * 4 * fDeltaTime + (1 - 4*fDeltaTime) * CurrentCameraDistance,0,DesiredCameraDistance) : DesiredCameraDistance;
HitLocation = CamStart + Normal(HitLocation-CamStart) * CurrentCameraDistance;
CameraOffsetRatio = CurrentCameraDistance/VSize(out_CamLoc - CamStart);
out_CamLoc = HitLocation;
bObstructed = true;
}
else
{
DesiredCameraDistance = VSize(out_CamLoc-CamStart);
CurrentCameraDistance = (fDeltaTime < 0.5f) ? FClamp(DesiredCameraDistance * 4 * fDeltaTime + (1 - 4*fDeltaTime) * CurrentCameraDistance,0,DesiredCameraDistance) : DesiredCameraDistance;
HitLocation = CamStart + Normal(out_CamLoc - CamStart) * CurrentCameraDistance;
CameraOffsetRatio = CurrentCameraDistance/VSize(out_CamLoc - CamStart);
out_CamLoc = HitLocation;
}
if (Trace(HitLocation, HitNormal, out_CamLoc, CamStart, false, vect(12,12,12)) != None)
{
out_CamLoc = HitLocation;
return false;
}
/*Again thanks for fall, for this. It just inside character collision detection*/
tempCamStart = CamStart;
tempCamStart.Z = 0;
tempCamEnd = out_CamLoc;
tempCamEnd.Z = 0;
if(bObstructed && (VSize(tempCamEnd - tempCamStart) < CylinderComponent.CollisionRadius*1.25) && (out_CamLoc.Z<Location.Z+CylinderComponent.CollisionHeight) && (out_CamLoc.Z>Location.Z-CylinderComponent.CollisionHeight))
{
SetHidden(true);
}
else
SetHidden(false);
return !bObstructed;
}
Bookmarks