class MyPawn extends GamePawn;
var float CamOffsetDistance; //distance to offset the camera from the player in unreal units
var float CamMinDistance, CamMaxDistance;
var float CamZoomTick; //how far to zoom in/out per command
var float CamHeight; //how high cam is relative to pawn pelvis
simulated function SetMeshVisibility(bool bVisible)
{
// Handle the main player mesh
if (Mesh != None)
{
Mesh.SetOwnerNoSee(!bVisible);
}
}
//override to make player mesh visible by default
simulated event BecomeViewTarget( PlayerController PC )
{
local UTPlayerController UTPC;
Super.BecomeViewTarget(PC);
if (LocalPlayer(PC.Player) != None)
{
UTPC = UTPlayerController(PC);
if (UTPC != None)
{
//set player controller to behind view and make mesh visible
UTPC.SetBehindView(true);
SetMeshVisibility(UTPC.bBehindView);
//Show Crosshair = false, hide = true
UTPC.bNoCrosshair = true;
}
}
}
simulated function FaceRotation(rotator NewRotation, float DeltaTime)
{
// Do not update Pawn's rotation if no accel
if (Normal(Acceleration)!=vect(0,0,0))
{
if ( Physics == PHYS_Ladder )
{
NewRotation = OnLadder.Walldir;
}
else if ( (Physics == PHYS_Walking) || (Physics == PHYS_Falling) )
{
NewRotation = rotator((Location + Normal(Acceleration))-Location);
NewRotation.Pitch = 0;
}
NewRotation = RLerp(Rotation,NewRotation,0.1,true);
SetRotation(NewRotation);
}
}
//orbit cam, follows player controller rotation
simulated function bool CalcCamera( float fDeltaTime, out vector out_CamLoc, out rotator out_CamRot, out float out_FOV )
{
local vector HitLoc,HitNorm, End, Start, vecCamHeight;
vecCamHeight = vect(-20,20,0);
vecCamHeight.Z = CamHeight;
Start = Location;
End = (Location+vecCamHeight)-(Vector(Controller.Rotation) * CamOffsetDistance); //cam follow behind player controller
out_CamLoc = End;
//trace to check if cam running into wall/floor
if(Trace(HitLoc,HitNorm,End,Start,false,vect(12,12 ,12))!=none)
{
out_CamLoc = HitLoc + vecCamHeight;
}
return true;
}
simulated function CamZoomIn()
{
if(CamOffsetDistance > CamMinDistance) CamOffsetDistance-=CamZoomTick;
}
simulated function CamZoomOut()
{
if(CamOffsetDistance < CamMaxDistance) CamOffsetDistance+=CamZoomTick;
}
defaultproperties
{
CamHeight = 40.0
CamMinDistance = 160.0
CamMaxDistance = 350.0
CamOffsetDistance=250.0
CamZoomTick=20.0
Begin Object Class=SkeletalMeshComponent Name=SkelComp
CastShadow=true;
bCastDynamicShadow=true;
bOwnerNoSee=false;
BlockRigidBody=true;
CollideActors=true;
BlockZeroExtent=true;
PhysicsAsset=PhysicsAsset'xxxxx'
AnimSets(0)=AnimSet'xxxx'
MorphSets(0)=MorphTargetSet'xxxx'
AnimTreeTemplate=AnimTree'xxxxx'
SkeletalMesh=SkeletalMesh'xxxx'
bHasPhysicsAssetInstance=True
End Object
Mesh=SkelComp
Components.Add(SkelComp)
Begin Object Class=SkeletalMeshComponent Name=SkelComps
CastShadow=true;
bCastDynamicShadow=true;
bOwnerNoSee=false;
BlockRigidBody=true;
CollideActors=true;
BlockZeroExtent=true;
bHasPhysicsAssetInstance=True
End Object
}
Bookmarks