Game Development Reference
In-Depth Information
There's more...
We could easily adopt this to have a different appearance around specific actors. For example,
we could have a thin white box drawn around any weapon. This would be done by using a
case or switch statement in our PostRender function, where it checks whether Actor is
of type Weapon or not. From there, we'd create a method similar to our DrawBoundingBox
that could be called something like DrawBoundingBoxWeap . The properties inside would
only have to be changed marginally to have a noticeable effect, such as having the box
completely wrap around the actor, changing the color, or how far away the actor is resting.
How it works...
PostRender is an event called by the game during each frame, and PostRender
calls DrawHUD , so really our call to DrawBoundingBox could occur in either function.
Regardless, we start by making a trace from our pawn's EyeLocaton . A check is then
performed to see if we run across an Actor object of type Pawn . If it is, then we call our
DrawBoundingBox function.
This is responsible for the appearance of our box, from the color to whether or not the
lines form one complete box around the pawn. Furthermore, it controls the thickness
of each rectangle as well.
DrawBoundingBox grabs the coordinates for the box by calling the GetBB function
which handles all of the heavy math for us. It grabs the bounding box from our pawn,
and using that sets the vectors for us to draw our four rectangles around the pawn.
Search Nedrilad ::

Custom Search