Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.74 KB | None | 0 0
  1. class HacknSlashPawn extends UTPawn
  2. config(HacknSlash);
  3.  
  4. var float CamOffsetDistance; //distance to offset the camera from the player in unreal units
  5. var float CamMinDistance, CamMaxDistance;
  6. var float CamZoomTick; //how far to zoom in/out per command
  7. var float CamHeight; //how high cam is relative to pawn pelvis
  8.  
  9. //stop aim node from aiming up or down
  10. simulated event PostInitAnimTree(SkeletalMeshComponent SkelComp)
  11. {
  12. super.PostInitAnimTree(SkelComp);
  13. AimNode.bForceAimDir = true; //forces centercenter
  14. }
  15.  
  16. simulated event PostBeginPlay()
  17. {
  18. super.PostBeginPlay();
  19. `Log("Custom Pawn up"); //debug
  20.  
  21. }
  22.  
  23. //override to make player mesh visible by default
  24. simulated event BecomeViewTarget( PlayerController PC )
  25. {
  26. local UTPlayerController UTPC;
  27.  
  28. Super.BecomeViewTarget(PC);
  29.  
  30. if (LocalPlayer(PC.Player) != None)
  31. {
  32. UTPC = UTPlayerController(PC);
  33. if (UTPC != None)
  34. {
  35. //set player controller to behind view and make mesh visible
  36. UTPC.SetBehindView(true);
  37. SetMeshVisibility(UTPC.bBehindView);
  38. UTPC.bNoCrosshair = true;
  39. }
  40. }
  41. }
  42.  
  43. //only update pawn rotation while moving
  44. simulated function FaceRotation(rotator NewRotation, float DeltaTime)
  45. {
  46. // Do not update Pawn's rotation if no accel
  47. if (Normal(Acceleration)!=vect(0,0,0))
  48. {
  49. if ( Physics == PHYS_Ladder )
  50. {
  51. NewRotation = OnLadder.Walldir;
  52. }
  53. else if ( (Physics == PHYS_Walking) || (Physics == PHYS_Falling) )
  54. {
  55. NewRotation = rotator((Location + Normal(Acceleration))-Location);
  56. NewRotation.Pitch = 0;
  57. }
  58.  
  59. SetRotation(NewRotation);
  60. }
  61.  
  62. }
  63.  
  64.  
  65. //orbit cam, follows player controller rotation
  66. simulated function bool CalcCamera( float fDeltaTime, out vector out_CamLoc, out rotator out_CamRot, out float out_FOV )
  67. {
  68. local vector HitLoc,HitNorm, End, Start, vecCamHeight;
  69.  
  70. vecCamHeight = vect(0,0,0);
  71. vecCamHeight.Z = CamHeight;
  72. Start = Location;
  73. End = (Location+vecCamHeight)-(Vector(Controller.Rotation) * CamOffsetDistance); //cam follow behind player controller
  74. out_CamLoc = End;
  75.  
  76. //trace to check if cam running into wall/floor
  77. if(Trace(HitLoc,HitNorm,End,Start,false,vect(12,12,12))!=none)
  78. {
  79. out_CamLoc = HitLoc + vecCamHeight;
  80. }
  81.  
  82. //camera will look slightly above player
  83. out_CamRot=rotator((Location + vecCamHeight) - out_CamLoc);
  84. return true;
  85. }
  86.  
  87. exec function CamZoomIn()
  88. {
  89. `Log("Zoom in");
  90. if(CamOffsetDistance > CamMinDistance)
  91. CamOffsetDistance-=CamZoomTick;
  92. }
  93.  
  94. exec function CamZoomOut()
  95. {
  96. `Log("Zoom out");
  97. if(CamOffsetDistance < CamMaxDistance)
  98. CamOffsetDistance+=CamZoomTick;
  99. }
  100.  
  101. defaultproperties
  102. {
  103. CamHeight = 140.0
  104. CamMinDistance = 40.0
  105. CamMaxDistance = 350.0
  106. CamOffsetDistance=350.0
  107. CamZoomTick=20.0
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement