Advertisement
Guest User

Untitled

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