Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class HacknSlashPawn extends UTPawn
- config(HacknSlash);
- 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
- //stop aim node from aiming up or down
- simulated event PostInitAnimTree(SkeletalMeshComponent SkelComp)
- {
- super.PostInitAnimTree(SkelComp);
- AimNode.bForceAimDir = true; //forces centercenter
- }
- simulated event PostBeginPlay()
- {
- super.PostBeginPlay();
- `Log("Custom Pawn up"); //debug
- }
- //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);
- UTPC.bNoCrosshair = true;
- }
- }
- }
- //only update pawn rotation while moving
- 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;
- }
- 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(0,0,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;
- }
- //camera will look slightly above player
- out_CamRot=rotator((Location + vecCamHeight) - out_CamLoc);
- return true;
- }
- exec function CamZoomIn()
- {
- `Log("Zoom in");
- if(CamOffsetDistance > CamMinDistance)
- CamOffsetDistance-=CamZoomTick;
- }
- exec function CamZoomOut()
- {
- `Log("Zoom out");
- if(CamOffsetDistance < CamMaxDistance)
- CamOffsetDistance+=CamZoomTick;
- }
- defaultproperties
- {
- CamHeight = 140.0
- CamMinDistance = 40.0
- CamMaxDistance = 350.0
- CamOffsetDistance=350.0
- CamZoomTick=20.0
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement