Enemy AI

I want to change how AI controls an Agent

  • Go to the prefab for the Agent.

  • Change the AI definition on the AI Controller component

This points to a particular instance of ProdigyAgentAiDefinition in Vault. You can modify that instance to create different behaviors for your AI. You might want Standard AI to be generic and reusable, but then have a separate "Chomper Monster" AI definition which might attack more frequently, track relentlessly, or be surprised for less time.

You can modify these to suit your needs, and create more to diversify how your AI agents behave in your game.

I want to understand how AI functions

circle-info

AI Agents have a ProdigyAgentAiController component by default and it is attached in ProdigyAgent.Awake(). When a Player Avatar is spawned, the Player is given control of some Agent via ProdigyAgent.AssignControlToPlayer(...).

If you want to spawn an AI Agent, just use an AgentPlacement and set the parameters you want.

All Character Agents in Prodigy function the same way. The only difference with Enemy AI is that they generate their own fake inputs based on their goals. Those inputs are fed back into the systems as if it were a player providing them.


Example A:

The default AI uses built in NavMesh. It will scan for a target, assign the target position in the NavMesh component, then evaluate desiredVelocity in order to know what Move and Look inputs might be.

Example B:

When it thinks it should fire, it will just change the Input Fire1 bool to true.

... This is generally the concept of the AI's output.


Instead of doing things in the world, the AI will instead just evaluate the world and use the standard Inputs to talk to the components and try to get the results it wants.

The normal Agent components are always reading the current input, so when the AI changes them, all of the regular component systems will go ahead and function like they normally would as if a Player were making those inputs.

This pattern standardizes all character behavior and puts the responsibility of descision making on the AI class while the responsibility of behavioral execution remains in the other appropriate Agent components. While there is some cross contamination for things like Root Motion, the goal is to maintain good separation of responsibility.

Last updated