Game Development Reference
In-Depth Information
// We simply use our rotation
POVRot = Rotation;
// If our Pitch is 0, then use RemoveViewPitch
if( POVRot.Pitch == 0 )
POVRot.Pitch = RemoteViewPitch << 8;
return POVRot;
Here we are using our point of view rotation, that is, the rotation from our camera and
not the pawn in this situation. This is what allows us to fire directly where the weapon
is pointed by following a trace from the weapon's socket. Previously the weapon
ignored our point of view and simply fired directly towards the center of the screen.
Our aim is corrected, but now we need a crosshair to display. This next function is
a large one, but we'll break it down into small and logical steps. Let's create our
CheckCrosshairOnFriendly() function as shown in the following code snippet:
* Draws the crosshair
function bool CheckCrosshairOnFriendly()
local float CrosshairSize;
local vector HitLocation, HitNormal,
StartTrace, EndTrace,
local actor HitActor;
local MyWeapon W;
local Pawn MyPawnOwner;
/** Sets the PawnOwner */
MyPawnOwner = Pawn(PlayerOwner.ViewTarget);
/** If we don't have an owner, then get out of the
function */
if ( MyPawnOwner == None )
return false;
/** Sets the Weapon */
W = MyWeapon(MyPawnOwner.Weapon);
Search Nedrilad ::

Custom Search