Game Development Reference
In-Depth Information
in a straight line forward until it reaches the player. This straightforward
approach can make the player feel under attack and that the NPC is a threat
and has bad intentions. In fact, the NPC has no intentions whatsoever. It is
just a computer algorithm. This illustrates how the simplest of programming
feats can create a believable character. Although you will examine
numerous techniques in this chapter to program intelligence , sometimes
complex AI systems are not required just to achieve the behavior you want
in your artificial characters.
In an open game environment, the easiest way to determine if an NPC has
seen the player is to use simple vector calculations. As shown in Figure 5.1 ,
a field of vision is defined for an NPC based on the direction it is facing, its
position, visible range, and the angle of its vision ( α ).
If a player is inside this range the NPC can be said to have detected the
presence of the player (see player 1); if not, the player is still hidden (as is the
case with player 2). The problem is very similar to that in Chapter One where
vectors were being calculated for the pirate to follow to the treasure. Instead
FIG 5.1 Vectors between an NPC
and players used to determine line
of sight.
Search Nedrilad ::




Custom Search