Game Development Reference
In-Depth Information
CrosshairSize = 28 * (Canvas.ClipY / 768) *
(Canvas.ClipX /1024);
Canvas.SetDrawColor(100,100,128,255);
// Crosshair in center of trace
Canvas.SetPos(ScreenPos.X - (CrosshairSize * 0.5f),
ScreenPos.Y -(CrosshairSize * 0.5f));
Canvas.DrawTile(class'UTHUD'.default.AltHudTexture,
CrosshairSize, CrosshairSize, 600, 262, 28, 27);
return false;
}
This is the same information we posted in the previous recipe, but we have an if
statement checking if our HitActor parameter is equal to None . When drawing
our trace from the weapon's socket, we check to see if we've run across any actors,
as seen by the following bit of code:
/** If we haven't hit any actors... */
if (HitActor == None )
{
HitActor = (HitActor == None) ? None
: Pawn(HitActor.Base);
HitLocation = EndTrace;
ScreenPos = Canvas.Project(HitLocation);
}
If we have hit an actor of type Pawn , as seen by our typecast Pawn(HitActor.
Base) , then that is our HitActor parameter, otherwise our HitActor parameter
is set to None . With that said, our function should make a bit more sense now. If we
don't hit any pawns, the crosshair will be drawn gray.
2. But what if we do run across a pawn in our trace? Well let's add that functionality
now, just beneath our if ((Pawn(HitActor) == None)) statement for drawing
the gray crosshair.
/** Draws the crosshair for friendlies - Yellow */
CrosshairSize = 28 * (Canvas.ClipY / 768) *
(Canvas.ClipX /1024);
Canvas.SetDrawColor(255,255,128,255);
Canvas.SetPos(ScreenPos.X - (CrosshairSize * 0.5f),
ScreenPos.Y -(CrosshairSize * 0.5f));
Canvas.DrawTile(class'UTHUD'.default.AltHudTexture,
CrosshairSize, CrosshairSize, 600, 262, 28, 27);
return true;
 
Search Nedrilad ::




Custom Search