Creating a realistic NPC search
The way NPCs search in games helps create believably and makes the NPCs seem more human, as they go about searching for stimuli that they are reacting to. There are different types of searching an NPC can, and should perform depending on the situation and the stimuli, (Welsh, 2015) breaks these types of searches down.
When an NPC is performing a cautious search, this should be because "the NPC has been alerted, but does not know whether their target is hostile." (Welsh, 2015). This can be caused by sounds using techniques different games employ, such as in Metal Gear Solid, the player can knock on a wall, or in other games the player can make a verbal noise such as the whistle in Assassin's Creed.
Another type of search that (Welsh, 2015) talks about is an aggressive search, this is where the NPC knows that what they are searching for is hostile, some stimuli to this could be spotting the player or hearing a hostile sound such as a gunshot.
It is important to telegraph to the player that the NPC is changing state as players need "to be able to identify what will and will not cause NPCs to react". (Welsh, 2015). When NPCs transition between states the easiest way for the game to show this and the player to understand is through the use of audio and animations. Some NPC might have a line of dialogue, while others might change their stance, or perform some other kind of animation/dialogue or both.
(Welsh, 2015) goes on to explain that there are two phases to a search, phase one is where the NPC will search the last place the stimuli was seen or heard, but there should also be a limit on how many NPCs will investigate the stimuli. When performing a cautious search, such as reacting to a whistle, or a coin being thrown, once the NPC has reached the location, "there is no further need to progress into the second search phase" (Welsh, 2015). Unlike the cautious search, if the NPCs are searching in an aggressive capacity, once the initial location of the stimulus has been investigated, the NPCs involved should move onto phase two.
Phase two should cause the NPCs to search a wider area to try and locate their target as they know they are facing a hostile. To perform this phase of the search there should be a "search coordinator that NPCs register with" (Welsh, 2015). This is because all NPCs should be working together as a cohort to search locations given to them by the coordinator. Phase two should last until all locations proposed by the coordinator have been search or a timer has expired.
The coordinator should work to direct NPCs to specified locations that the player could have moved to, without giving the player's position away, once a location has been searched it should be marked as such so that NPCs don't recover ground that has already been searched (unless that's the intended behaviour).
There are two ways to end a search, either the NPCs find the player, or the timer has ran out. With both occasions, as stated above the NPC should telegraph to the player that they are changing state, whether it's because they shout "They're over here" or "They must have left, can't find them" or some other kind of dialogue or animation. (Welsh, 2015) ends by explaining how NPCs should begin leaving the search individually because "stopping all NPCs simultaneously looks very strange" (Welsh, 2015).
Reference List
Welsh, R. (2015) “Looking for Trouble: Making NPCs Search Realistically” in Game AI Pro 2, edited by Steve Rabin. Boca Raton, FL: CRC Press 2015, pp. 305-312.
When an NPC is performing a cautious search, this should be because "the NPC has been alerted, but does not know whether their target is hostile." (Welsh, 2015). This can be caused by sounds using techniques different games employ, such as in Metal Gear Solid, the player can knock on a wall, or in other games the player can make a verbal noise such as the whistle in Assassin's Creed.
Another type of search that (Welsh, 2015) talks about is an aggressive search, this is where the NPC knows that what they are searching for is hostile, some stimuli to this could be spotting the player or hearing a hostile sound such as a gunshot.
It is important to telegraph to the player that the NPC is changing state as players need "to be able to identify what will and will not cause NPCs to react". (Welsh, 2015). When NPCs transition between states the easiest way for the game to show this and the player to understand is through the use of audio and animations. Some NPC might have a line of dialogue, while others might change their stance, or perform some other kind of animation/dialogue or both.
(Welsh, 2015) goes on to explain that there are two phases to a search, phase one is where the NPC will search the last place the stimuli was seen or heard, but there should also be a limit on how many NPCs will investigate the stimuli. When performing a cautious search, such as reacting to a whistle, or a coin being thrown, once the NPC has reached the location, "there is no further need to progress into the second search phase" (Welsh, 2015). Unlike the cautious search, if the NPCs are searching in an aggressive capacity, once the initial location of the stimulus has been investigated, the NPCs involved should move onto phase two.
Phase two should cause the NPCs to search a wider area to try and locate their target as they know they are facing a hostile. To perform this phase of the search there should be a "search coordinator that NPCs register with" (Welsh, 2015). This is because all NPCs should be working together as a cohort to search locations given to them by the coordinator. Phase two should last until all locations proposed by the coordinator have been search or a timer has expired.
The coordinator should work to direct NPCs to specified locations that the player could have moved to, without giving the player's position away, once a location has been searched it should be marked as such so that NPCs don't recover ground that has already been searched (unless that's the intended behaviour).
There are two ways to end a search, either the NPCs find the player, or the timer has ran out. With both occasions, as stated above the NPC should telegraph to the player that they are changing state, whether it's because they shout "They're over here" or "They must have left, can't find them" or some other kind of dialogue or animation. (Welsh, 2015) ends by explaining how NPCs should begin leaving the search individually because "stopping all NPCs simultaneously looks very strange" (Welsh, 2015).
Reference List
Welsh, R. (2015) “Looking for Trouble: Making NPCs Search Realistically” in Game AI Pro 2, edited by Steve Rabin. Boca Raton, FL: CRC Press 2015, pp. 305-312.