Game Development Reference
In-Depth Information
Aiming Reticule
An aiming reticule is a standard HUD element used in most first- and third-person
games that have ranged combat. It allows the player to know where he is aiming
as well as to acquire further information regarding the target (such as whether the
target is a friend or foe). Whether the reticule is a traditional crosshair or more
circular, the implementation ends up being roughly the same. In fact, the imple-
mentation is extremely similar to mouse picking as discussed in Chapter 8 .
As with a mouse cursor, with an aiming reticule there will be a 2D position on the
screen. We take this 2D position and perform two unprojections: one at the near
plane and one at the far plane. Given these two points, we can perform a ray cast
from the near plane point to the far plane point. We can then use the physics cal-
culations discussed in Chapter 7 , Physics , ” to generate a list of all the objects the
ray cast intersects with. From the resultant list, we want to select the first object
that the ray cast intersects with. In a simple game, it may be the case that the first
object the ray cast intersects with is also the one whose position is closest to the
near plane point. But with larger objects, that may not always be the case. So for
more complex games, we might need to actually compare the points of intersec-
tion between the ray and each object.
Once we know which object the aiming ray intersects with, we can then check to
see whether it's a friendly, foe, or an object that can't be targeted. This then de-
termines what color the reticule should be rendered in—most games use green to
signify a friendly, red to signify a foe, and white to signify that the object is not
a target (though this coloring scheme is not particularly usable for a player who
happens to be red-green color blind). Figure 10.5 illustrates a couple of different
scenarios with an aiming reticule in a hypothetical game.
Search WWH ::




Custom Search