Chapter 8
243
- This occurs in our PostRender() function within our TutorialHUD class.
Let's add the variables we'll need right now.
local Actor HitActor;
local Vector HitLocation, HitNormal, EyeLocation;
local Rotator EyeRotation;
- A check is necessary to verify that we have a player controller, and whether we
grab the camera location and rotation or not. This will be used for our trace.
/*Check for pawn owner/
if (PlayerOwner != None)
{
/* Grab player camera loc & rot /
PlayerOwner.GetPlayerViewPoint(EyeLocation, EyeRotation);
- The pawn's EyeLocation is where we start the trace and extend from. We check
to see if each actor is actually a pawn, and anything else is discarded, including
our own pawn.
/ Trace to see where player is looking. Used to ignore
specific objects /
ForEach TraceActors(class'Actor', HitActor, HitLocation,
HitNormal, EyeLocation + Vector(EyeRotation) *
PlayerOwner.InteractDistance, EyeLocation,
Vect(1.f, 1.f, 1.f),, TRACEFLAG_Bullet)
{
/ If the hit actor is the player owner, player
owner's pawn or if hit actor isn't visible, ignore
it */
if (HitActor == PlayerOwner ||
HitActor == PlayerOwner.Pawn ||
!FastTrace(HitActor.Location, EyeLocation))
{
continue;
}
/* Checks if the actor is a pawn /
if (HitActor.IsA('Pawn'))
{
/ Draws the 2D brackets */
RenderBoundingBox(HitActor);
}
If a pawn is within our trace, we then call our RenderBoundingBox() function
to draw a box around the pawn.