Game Development Reference
In-Depth Information
Figure 10.6 Radar (in the top right corner) in Unreal Tournament 3 .
Two main things must be done in order to get a radar to work. First, we need a
way to iterate through all of the objects that could show up on the radar, and check
whether or not they are within the range of the radar. Then any objects that are
within range of the radar must be converted into the appropriate 2D offset from
the center of the radar in the UI. Both when calculating the distance and convert-
ing into a 2D offset, we want to ignore the height component. This means we are
essentially projecting the radar objects onto the plane of the radar, which sounds
harder than it actually is in practice.
But before we do these calculations, it's worthwhile to declare a struct for a
radar blip , or the actual dot that represents an object on the radar. This way, it
would be possible to have different size and color blips depending on the target in
question.
Click here to view code image
struct RadarBlip
// The color of the radar blip
Color color = Color .Red
// The 2D position of the radar blip
Vector2 position
// Scale of the radar blip
Search WWH ::




Custom Search