UnrealScript Game Programming Cookbook

(Chris Devlin) #1

Scripting a Camera System


76

super.PostBeginPlay();
'Log("TutorialPlayerControllerSSC up");
}

/**********************************************************
*** FOR ALL CAMERAS ***
* Rotator where the pawn will be aiming the weapon.
* Will be different, depending on which camera system we
* are using.
************************************************************/
function Rotator GetAdjustedAimFor
(Weapon W, vector StartFireLoc)
{
returnPawn.GetBaseAimRotation();
}


  1. The next function we add allows our projectiles to fire in the correct direction. We are
    overriding UpdateRotation, so that the projectiles use the pawn's rotation and not
    the camera's rotation when firing. Without this, you'll notice that projectiles always fire
    in the same direction, and towards the camera. The following is that bit of code:
    /**

    • Forces the weapon to fire in the direction the pawn is
      facing
      **/
      functionUpdateRotation( float DeltaTime )
      {
      local Rotator DeltaRot, newRotation, ViewRotation;




ViewRotation = Rotation;

/** Calculate Delta to be applied on ViewRotation */
DeltaRot.Pitch = PlayerInput.aLookUp;
ProcessViewRotation( DeltaTime, ViewRotation, DeltaRot );
SetRotation(ViewRotation);
NewRotation = ViewRotation;

if ( Pawn != None )
Pawn.FaceRotation(NewRotation, deltatime);
}
Free download pdf