Game Development Reference
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 */
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) *
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
if (HitActor == PlayerOwner ||
HitActor == PlayerOwner.Pawn ||
/** Checks if the actor is a pawn */
/** Draws the 2D brackets */
If a pawn is within our trace, we then call our RenderBoundingBox() function
to draw a box around the pawn.