Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17825

Memory Markers

$
0
0
Memory is something that is often overlooked in combat games, more often than not when a character becomes aware of you in a combatative action game, they remain aware until dead. Sometimes they may run a countdown when they lose sight of the player and lapse back into their patrol state if that ends before they find them.

Neither of these techniques looks particularly intelligent. The AI either looks unreasonably aware of you, or unrealistically gullible, in that they go about their business after they've lost track of you for a few seconds.

A memory marker is a simple trick (The UE4 implementation of which can be seen here) that allows you to update and play with the enemy's perception. It is a physical representation of where the enemy 'thinks' the player is.

In its simplest form, it has two simple rules:
  • The AI use this marker for searches and targeting instead of the character
  • The marker only updates to the player's position when the player is in view of the AI
this gives you a number of behaviours for free. For example, the AI will look as if you have eluded them when you duck behind cover and they come to look for you there. Just from this minor change you now have a cat-and-mouse behaviour that can lead to some very interesting results.


Capture.png


I was pleased to see that Naughty Dog also use this technique. In this Last of Us editor screen-grab, you can see their enemy marker (white) has been disconnected from the hiding character

It is also very extensible - in more complicated implementations (covered in future video tutorials) a list of these markers is maintained and acted upon. This lets us do things like have the AI notice a pickup when running after the player, and return to get it if they ever lose their target.

So how do we start to go about coding these markers?


In my experience the most important thing when coding this system in various forms is that your memory markers, in code and their references in script, must be nullable.

This provides us with a very quick and easy way of wiping these markers when they are no longer needed, or querying the null state to see if the agent has no memory of something - and therefore if we need to create it.

The first pass implementation of these markers simply has two rules:

  1. You update the marker for a character to that character's location when its been seen by an enemy.
  2. You make the AI's logic - search routines and so on - act on this marker instead of the character

It's worth mentioning that each AI will need one of these markers for every character on an opposing team, and every object they must keep track of.
Because of this, it is useful to populate some kind of array with these markers.

Think too, about how you can sort this list by priority. When the AI loses track of a target they can grab the next marker in the list which may be an objective, or a pickup they passed.

When the list is empty, they fall back to their patrol state.

Viewing all articles
Browse latest Browse all 17825

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>