Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Unicon 3.22 KB | None | 0 0
  1. class TMCPawn extends MobilePawn; // or UDKPawn
  2.  
  3. var vector ThirdPersonCamOffset1;
  4. var vector ThirdPersonCamOffset2;
  5. var vector ThirdPersonCamOffset3;
  6. var bool bInFirstPerson;
  7.  
  8. //comes from the Actor Class,used to decide which type of camera we want.
  9. Simulated function bool CalcCamera(float fDeltaTime, out vector out_CamLoc, out rotator out_CamRot, out float out_FOV )
  10. {
  11.     local TMCPlayerController OIPC;
  12.     OIPC= TMCPlayerController(Owner);
  13.     out_FOV = 100.0;
  14.     if(OIPC != None)
  15.     {
  16.         If(OIPC.ZoomCamPoint==0) //Handle BehindView
  17.         {
  18.             GetActorEyesViewPoint(out_CamLoc, out_CamRot); //get the actors view for first person
  19.         }
  20.         else
  21.         {
  22.             CalcThirdPersonCamera(fDeltaTime, out_CamLoc, out_CamRot, out_FOV, OIPC.ZoomCamPoint);
  23.         }
  24.     return true;
  25.     }
  26.     else
  27.     {
  28.         If(bInFirstPerson) //Handle BehindView
  29.         {
  30.             GetActorEyesViewPoint(out_CamLoc, out_CamRot); //get the actors view for first person
  31.             RemoveMeshVisibility(true);
  32.         }
  33.  
  34.         else
  35.         {
  36.             CalcThirdPersonCamera(fDeltaTime, out_CamLoc, out_CamRot, out_FOV);
  37.             RemoveMeshVisibility(false);
  38.         }
  39.         return True;
  40.     }
  41. }
  42.  
  43.  
  44. //function used to calculate the third person camera, uses same arguments as CalcCamera
  45. simulated function bool CalcThirdPersonCamera(float fDeltaTime, out
  46. vector out_CamLoc, out rotator out_CamRot, out float out_FOV, optional
  47. int CamZoom)
  48. {
  49.     local vector CamLoc, HitLocation, HitNormal, CamX, CamY, CamZ;
  50.     CamLoc = Location; //get Current Location of the Camera
  51.     //gets the actual players rotation and puts it in to the players xyz axes
  52.     GetAxes(out_CamRot, CamX, CamY, CamZ);//to get axes of the player based on
  53.    
  54.     //brings the current location of the camera based off Axis and Offset
  55.  
  56.     switch(CamZoom)
  57.     {
  58.     case 1:
  59.         out_CamLoc = CamLoc - CamX*ThirdPersonCamOffset1.X +
  60.         ThirdPersonCamOffset1.Y * CamY + ThirdPersonCamOffset1.Z * CamZ;
  61.         break;
  62.     case 2:
  63.         out_CamLoc = CamLoc - CamX*ThirdPersonCamOffset2.X +
  64.         ThirdPersonCamOffset2.Y * CamY + ThirdPersonCamOffset2.Z * CamZ;
  65.         break;
  66.     case 3:
  67.         out_CamLoc = CamLoc - CamX*ThirdPersonCamOffset3.X +
  68.         ThirdPersonCamOffset3.Y * CamY + ThirdPersonCamOffset3.Z * CamZ;
  69.         break;
  70.     default:
  71.     Break;
  72.    
  73.     }
  74.  
  75.     //used to cause collission for camera
  76.     if (Trace(HitLocation, HitNormal, out_CamLoc, CamLoc, false, vect(12,12,12)) != None)
  77.     {
  78.         //go to first person view if cornered
  79.         GetActorEyesViewPoint( out_CamLoc, out_CamRot );
  80.         RemoveMeshVisibility(true); //set mesh to invisible
  81.         return false;
  82.     }
  83.  
  84.     else if(Mesh.bOwnerNoSee==true) //if true lets turn it back off
  85.     {
  86.         Mesh.SetOwnerNoSee(false);
  87.     }
  88.     return true;
  89. }
  90.  
  91. //used to remove or add the player mesh
  92. function RemoveMeshVisibility(bool Allow)
  93. {
  94.     Mesh.SetOwnerNoSee(Allow);
  95. }
  96.  
  97. defaultproperties
  98. {
  99.    
  100. bInFirstPerson=false
  101. ThirdPersonCamOffset1=(X=-80.0,Y=8.0,Z=-32.0)
  102. ThirdPersonCamOffset2=(X=200.0,Y=8.0,Z=100.0)
  103. ThirdPersonCamOffset3=(X=-80.0,Y=-80.0,Z=-80.0)
  104.  
  105. Begin Object class=SkeletalMeshComponent Name=MyPawnMesh
  106.     SkeletalMesh=SkeletalMesh'MyPackage.soldier'
  107.     //Scale3D=(X=0.8,Y=0.8,Z=0.8)
  108.     //AnimSets(0)=AnimSet'CH_AnimHuman.Anims.K_AnimHuman_BaseMale'
  109.     //AnimTreeTemplate=AnimTree'CH_AnimHuman_Tree.AT_CH_Human'
  110.     HiddenGame=FALSE
  111.     HiddenEditor=FALSE
  112. End Object
  113. Mesh=MyPawnMesh
  114. Components.Add(MyPawnMesh)
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement