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
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:- You update the marker for a character to that character's location when its been seen by an enemy.
- You make the AI's logic - search routines and so on - act on this marker instead of the character
A simple idea that will lead to some cool AI. Very nice sir.