Enemy AI

To make an AI, just replace the ProdigyAgent with ProdigyAgentAi. You can also just use an existing demo prefab for a quick template.

All Characters 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.

Example C:

If it's target is too close or too far, it may evaluate it's available inventory of weapons and decide that index 2 has the ideal range for this battle, and flag the Swap input until it reaches that index.

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 appropriate Agent components.

Last updated

Was this helpful?