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 it's been seen by an enemy.
- 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.