Powerful Decision-Making Systems
AI in MultiGame can serve a wide variety of roles in a wide array of game genres. By combining AI components as needed, you can build virtually any desired behavior.
Procedures and Tasks
This component allows you to describe a list of Messages to be sent in order, with an optional delay in between. You can have multiple sequencers on an object, and you differentiate between them using their Designator.
Useful for AI, or for combining MultiGame behaviors in complex ways, for example to create magical spells or to create timed missions with multiple events for the player.
To use the Behavior Sequencer:
Add other MultiGame components like NavModule or Sounder
Decide what order you wish the events to occur in, and add them to the Sequence
Give the sequence a name by filling in the Designator field
Send a message from any other MultiGame component, UI element, or graphical programming system as follows:
StartSequence - this message tells MultiGame that we want to start one of the Behavior Sequencers on this object
Designator - send the name of this Behavior Sequencer (it's Designator) as a string
When you do this, MultiGame will stop all Behavior Sequencers on this object (unless Exclusive is un-checked for this one) and start this Behavior Sequencer. It will call all of the messages in the Sequence and then stop, unless you enable Loop.
AI Mind for advanced decision-making
The Utility Module is a powerful decision engine, which allows you to create lifelike AI which have desires, and act upon these desires based on changes in the environment.
In addition to traditional game AI agents, the Utility Module is also capable of controlling a wide variety of behavior, and even the overall state of the game itself.
To use it, first decide what kind of "desires" the AI should have, and add these to the Directives list. Give each one an appropriate name. If you want the AI to want a thing more over time, increase the Change Per Sec for that Directive. The Desired Object is a thing that the AI "wants" to have in the scene, so it will follow this directive preferrentially if there aren't enough of the object with this tag in the scene.
Most importantly, assign a Sequence Designator to this Directive, and make sure that there is a matching Behavior Sequencer with the same Designator on it, so that the Utility Module can call it when ready.
To understand how the Utility Module selects a Directive, we must talk about Utility and Valence.
The Utility AI constantly evaluates each Directive, and when a new one becomes the one with the highest Utility, it selects that Directive.
The Utility is a value between 0 and 1 representing a percentage of desire. The Utility Graph describes how the Utility increases as Valence increases.
Valence is a proxy for frustration, as valence increases the Utility ( which you can think of as the desire to do a thing) also increases.
Utility is calculated by using the Valence as the X Axis of the Utility Graph, and the Y Axis is therefore the Utility. So, if the Valence is 0.5, and the graph value at x = 0.5 is y = 0.5, then the Utility is 0.5.
This will be the case by default, as the default graph is linear.
The Nav Module gives designers full control over AI navigation using Unity's powerful Nav Mesh system.
How to create an AI agent
Using Utility Module and Behavior Sequencer
First, open the MultiGame Toolbar by clicking the MultiGame menu item at the top of the screen, and selecting the toolbar.
Next, select the object or character you wish to become an AI
Click the "AI" tab on the toolbar, and select "Utility AI Brain" and "Navigation"
Add at least 2 "Directives" to the Utility Module - these are things which the AI can desire to do
For each Directive, add a "Behavior Sequencer" which represents this task as a list of commands
For each Directive, the Sequence Designator on the Directive must match the Designator on the Behavior Sequence to be called when that Directive is the most desirable.
Set a starting "Valence" for each Directive. By default the Valence and Utility are the same, but you may edit the Utility Graph to cause Utility to change non-linearly as Valence increases
At any given time, the Utility Module selects the Directive (and thus calls the Behavior Sequencer) which has the highest Utility
If you want the desire (Utility) for a Directive to increase non-linearly, you can accomplish this by editing the Utility Graph. Otherwise, leave it at default (recommended for beginners)
Add a "Satisfaction Value" to each directive, this should usually be a negative number between 0 and -1
At the end of the Behavior Sequencer for a given Directive, add the "SatisfyDirective" message with the argument being the name of that Directive (string), this way the AI can be satisfied by the actions performed, and select a new Directive