Game Career Guide is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.

Get the latest Education e-news
  • The Importance Of Reactions In Game AI

    - Sergio Ocio Barriales

  • Mitigating Repetition

    In development, we are oftentimes limited by budget or time constraints. This mainly means that we can only afford to solve a finite number of problems and try to minimize unplanned, less polished situations as best we can. Applied to reactions, this means we can probably only build a handful of specialized reactions for certain important or frequent stimuli, while many others will be more generic by necessity.

    Now, this is not strictly a bad thing. Going back to the discussion about repetition in video game AI, it is important to note that the more specific or exotic a reaction is, the easier it will be for players to notice it when it happens a second time, a third time, and so on. Soon they will see it every time, and the suspension of disbelief will be broken.

    Voice Repetition

    Think about the following case. Let's say we are playing a stealth game, and the player is spotted near a water well. An agent shouts "he is BY THE WELL" and combat breaks out. The player hides but is spotted again at the same location almost right away. "He is BY THE WELL", the AI repeats. "BY THE WELL". Although the fact that our AI is calling out a specific location will most likely surprise the player and be noted as good AI (#Orkin15), the perception of the player will quickly turn into annoyance when things get repeated over and over again.

    A solution for this problem could come with the addition of cooldowns, or somehow remembering that certain "cool moments" have already recently been played, so it is better to hold off and use a generic response instead. More general call-outs, such as "OVER THERE" or "I SEE HIM" are less specific, and therefore less memorable. Building this type of system and working with your writers can lead to great results (#Ruskin12).

    Repetition in Groups

    Another problem we can face is related to group reactions. If multiple AI agents are on screen (the closer they are, the more noticeable this problem will be) and all play the same reaction simultaneously, we are giving players another reason to break their immersion and just spot something that simply "does not look good". Going back to our stealth game example, we have a group of two NPCs that are unaware of the player. The player then decides to engage our group and starts shooting around the agents, which triggers a "shots fired" reaction. At that point, both our agents play a reaction animation and transition into a combat state. There are two problems with this picture: they reacted the same way, and they reacted at the same exact time.

    For asset repetition, we could tackle the problem simply by brute force (i.e. add variations to our animations, which is always a good idea). But, again, in a world ruled by budget constraints, this may not always be possible. Different approaches can be taken in this case, such as limiting the number of agents that can present a behavior or reaction at the same time, mix different types of appropriate reactions (e.g. have some of the NPCs run away instead of playing an animation) or some other procedural animation techniques (#Shroff15).

    For timing, slight time delays go a long way toward mitigating the ‘simultaneous reaction' problem. In general, if all of the NPCs in our group react simultaneously, on the exact same frame (even if each of them is using a different, unique animation), something will feel off to the player. Humans have different reaction times - generally between 0.2 and 0.4 seconds (#Rabin15) -, so simultaneous responses will look robotic and unrealistic. To mitigate this problem, we can add some randomization to our reaction times - this will make our group reactions feel more natural.

    Hit Reactions

    Hit reactions are those played as a result of direct contact (or collision) with some other entity or object (e.g. being punched or hit by a bullet). Virtually every game uses this type of reaction in some form. They are intended to provide immediate feedback so the player knows that an attack has connected. The magnitude of the reaction is normally dictated by a combination of factors such as the force and direction of the impact, and the location of the hit (e.g. headshot vs. shooting a limb). Bad hit reactions can easily break the suspension of disbelief. For example, if we play a very painful hit reaction and immediately after our character goes back to being happy and without showing any sign of damage, this could be perceived as inconsistent or implausible. Maintaining some sort of memory, such as a damage state, could be a good way to solve some of these issues. Good hit reactions can be crucial for gameplay (#Campbell18).

    Perception Reactions

    A perception system is a set of simulated senses that allow AI agents to detect changes in their environment. Most games use "sight" as the main way for the AI to gather information; this sense is usually implemented as a combination of volume checks and raycasts that help the agents determine if an entity is in their field of view and needs to be recognized. "Hearing" is also commonly used; it can be implemented as some type of distance check from the source of the noise to the NPC. This topic is complex and outside of the scope of this post, but many good resources on the subject, such as (#Walsh15) and (#Welsh15).

    A perception reaction is the consequence of an event captured by the AI's perception systems (e.g. seeing the player or hearing a loud noise). Having a strong set of these reactions is key if we want to build good, responsive, believable AI, and there are some basic types that every good game AI should have.


comments powered by Disqus