Table of Contents

Built-in actions and considerations

Wise Feline contains a set of built-in actions and considerations which help you when prototyping things quickly or even building the real AI of your game. These can be found in the ActionAndConsiderationLibrary folder in the UtilityAI folder of the package.

Design philosophy

Built-in actions and considerations work on the assumption that you put all the data the AI needs in the blackboards of the GameObjects participating in the AI. The objects might be something in the environment which you can interact with or an agent or a player controlled object.

Sometimes the data might be stored as a set of tags if it is static info about the object or can benefit from spatial queries like give me the objects with this property in my 100 meters radius.

For these assumptions we have actions and considerations which can read/write blackboard data, tags and smart objects and we allow you to search influence maps without writing code. Also you can write into influence maps without writing code using the InfluencerAgent. You can create influence map views which are multiple maps combined by math operations without writing a single line of code.

We even have some animation integration which works with the built-in actions and considerations and answers some of your needs.

This all means that you can easily prototype and even complete your AI by writing a bit of code to integrate animations or doing very specific or performance sensitive behaviors. To proove the points above, we built the more complex life simulation demo with less than 10 custom actions and considerations combined and even those were not that much code and mostly added some visual effects/animations to the built-in ones.

Movement components

The movement actions need to move agents because without movement we could not make that many actions :) That however needs movement to be abstracted a bit so your agents don't have to follow our code too much. So we made multiple movement component which you can choose from.

The different ones implement an interface called IAIMovement so the actions don't differentiate between an agent which uses a NavMeshAgent component or a CharacterController or any other way to move.

The interface has two methods to move to a position and one for stopping to move. They are supposed to be called only once and then the movement component will move the agent there. The Methods aren't supposed to be called every frame. The movement methods do the same thing but the different overloads take the destination position by different ways. You can give a GameObject to this and ask to move to its position or give it a Vector3 and ask to move to it. Feel free to use them in your own actions too.

These are the components so far.

CharacterControllerBasedAIMovement

You can attach this component to an agent to move it using built-in actions if the agent has a CharacterController component.

You can attach this component to an agent to move it using built-in actions if the agent has a NavMeshAgent component.

Animation integration

To integrate animations with your AI actions, your actions need to set animator's parameters so it knows what action is executing. We have a parameter in built-in actions which allow you to set a trigger when the action starts. We also allow you to set a velocity parameter in movement components to make them more useful in real-world scenarios and also to teach you how to potentially integrate more complex animation scenarios.

List of built-in Actions

We have created a group of actions which are general enough which can simulate many of the actions you need for your games. You will need to inherit from them to apply animations and other custom things but they are a good starting point to create your AI. We will make them more powerful as time goes.

Most of our actions inherit from BlackboardActionBase which allows you to modify the agent's blackboard over time.

BlackboardActionBase

You will not use this action on its own most of the time but our other actions inherit from it.

This action has a BlackboardChanger which allows you to apply a change to blaockboard values for the agent over time. The changer can apply a change once or multiple times with delay or every frame. It can even multiply the every frame changes of type float by delta time. The action has a boolean to reset the changer in OnStart which effectively is whenever the action is selected. You can also apply a delay at startup before starting the blackboard changes.

BlackboardActionWithSmartObjectTarget

Finds potential targets from smart objects and optionally claims and uses them. It also frees them in OnFinish if the claiming and using is switched on. Also the action will fail if it tries to claim/use the smart object unsuccessfully.

This action doesn't execute any animations or movement and just tries to find targets using the smart object search parameters specified and then optionally claim and use the chosen target in OnStart() (when the action starts executing) and then free the chosen target in OnFinish().

The search parameters are the smart object tags which the object should/should not have, the radius and the slot states of acceptable slots.

Read on smart objects for more information on how the search functionality works but basically you can say I want my object to have one of these tags and don't want it to have these other tags and you can also say if you want it to have any slot owned by you or any free slots or you don't care about the slots.

  • You need at least one consideration with NeedTarget set to true to evaluate the targets of this and choose the best one.

BlackboardActionWithTagTarget

This action updates its targets based on AI tags system and executes blackboard changes which you choose. The action doesn't do anything with the targets but it is useful because it will not execute if one of the targets don't get a high enough score for this action to win in the brain as the selected action.

For example: Using this action and correct properties you can increase the wormth key of the blackboard if the character is in proximity of any object with the fire tag. You set the radius to say 5 and add fire to include tags and add a TargetDistance consideration which chooses the target if it is close enough and maybe add a BlackboardFloatConsideration to only choose it when you have low wormth. There are actions to move toward fire as well so don't worry about it.

  • You need at least one consideration with NeedTarget set to true to evaluate the targets of this and choose the best one.

CreateGameObjectAction

This action creates gameobjects, can be used for shooting, providing loot and other similar things

It asks for the prefab of the object to create and the number of them needed and if it should create one after each delay or they all should be instantiated at once.

Also a checkbox shouldAdaptBrainRotation which if set then the object inherits the rotation of the agent creating it which is good for bullets and alike.

DestroySelfAction

Destroys the GameObject executing the action

This action takes a delay as a parameter and if the action is switched off before the delay finishes, the destruction will not happen.

DestroyTargetWithTagAction

Destroys the target object, can be used for killing, eating and similar actions.

The targets are found using the tag system.

The action takes the radius of the search and uses the agent's position as the center. The target should have at least one of the included tags and non of the excluded ones.

You need at least one consideration with NeedTarget set so it can evaluate targets to see if they are a good fit to destroy or not

Movement actions

These actions don't work if a movement component is not attached to the agent. See above for the list of them. The movement speed is whatever is set on the NavMeshAgent or any other movement component you attached to the agent.

MoveAndPatrol

Patrols the agent on the way points provided as children of a GameObject which is set on a blackboard key. Optionally can finish the action after one full cycle finished.

MoveToGameObjectAction

Moves the agent to the position of a GameObject set on a blackboard key. The action succeeds after it reaches the destination and fails if the movement method fails to move (returns false).

MoveToVector3Action

Moves the agent to the position of a Vector3 set on a blackboard key. The action succeeds after it reaches the destination and fails if the movement method fails to move (returns false).

MoveToTargetWithTag

Makes a list of potential targets using the AI Tag system and moves toward the chosen target if the action is selected to execute.

Needs a consideration with NeedTarget set so targets can be evaluated and chosen.

MoveToSmartObject

Finds a set of smart objects as potential trgets and if the action gets selected to execute then it moves toward the chosen target.

The search criteria can be specified for slots of the smart object to make sure we own a slot in the object/a free slot can be found. You can also choose none.

Needs a consideration with NeedTarget set so targets can be evaluated and chosen.

NoopAction

This action is our favorite and doesn't do anything. It optionally can stop movement too.

It can be used in cases that you only desire the agent to stop moving and probably change some blackboard attributes. Let's say you want to cancel a movement action which is moving the agent somewhere and you don't want anything to happen after cancelation. This is the action for those times. This was the programming job of the life sim demo.

List of built-in Considerations

Some considerations have specific requirements and some of them might only work with NeedTarget on or off. Also some considerations might return binary 0 or 1 values and some return a value between 0 and 1 and are continuous. Min and max range values matter for some of them as well.

These are all mentioned per consideration.

In a binary consideration, the values of your consideration curve between 0 and 1 don't matter because it always returns either 0 or 1.

And as said in the considerations page, if NeedTarget is false then the agent itself is sent to GetValue as target and if it is true, all targets of the action are sent to it one by one to get a score.

AITagConsideration

This consideration checks if the target or the executing agent has or doesn't have a specific tag. It takes a tag and also an operation enum which you can set to the desired tag and operation.

The ShouldHaveTag operation causes the consideration to return 1 if the object has the tag and 0 otherwise. The ShouldNotHaveTag operation returns 1 if the object does not have the tag and 0 otherwise.

  • This consideration is binary.
  • This consideration works both for targets and the executing agent.
  • The target of the consideration should have the AITags component for this to work.

BlackboardBoolConsideration

Checks a boolean key in a blackboard. This returns 1 if the key exists and is true and if it doesn't exist or is false returns 0.

  • This consideration is binary.
  • This consideration works both for targets and the executing agent.
  • The target of the consideration should have the BlackBoard component for this to work.

BlackboardFloatConsideration

Checks afloat key in the blackboard and if it exists, returns its value, otherwise returns 0.

You can invert the value of this consideration and the value is always normalized between min range and max range.

  • This consideration is continuous.
  • This consideration works both for targets and the executing agent.
  • The target of the consideration should have the BlackBoard component for this to work.

BlackboardGameObjectDistanceConsideration

Returns the distance between the executing agent and a GameObject which is specified in a key in the blackboard.

You can invert the value of this consideration and the value is always normalized between min range and max range.

For example, if you want distances less than 20 meters to be considered then you should set max range to 20. Any value larger than 20 will be normalized to 20 and returns 1 and 10 will return 0.5 and 0 will return 1. You can invert the results if you want lower distances to return values closer to 1 and higher ones move toward 0.

  • This consideration is continuous.
  • This consideration works both for targets and the executing agent.
  • The target of the consideration should have the BlackBoard component for this to work.

BlackboardIntRangeconsideration

Checks an integer key in the blackboard and returns its value. If the key doesn't exist then it returns 0.

You should set the range to values which indicate the possible values of the int. if the int can be 1, 2 or 3 then the min range should be 1 and max range should be 3 and then 1 will return 0, 2 will return 0.5 and 3 will return 1. You can invert the result with the checkbox if needed as well.

  • This consideration is continuous.
  • This consideration works both for targets and the executing agent.
  • The target of the consideration should have the BlackBoard component for this to work.

BlackboardIntValueConsideration

This consideration checks an int key in the blackboard and returns 1 if the value equals the expected value; otherwise, it returns 0.

  • This consideration is binary.
  • This consideration works both for targets and the executing agent.
  • The target of the consideration should have the BlackBoard component for this to work.

BlackboardConsiderationKeyExists

This consideration returns 1 if the specified key name exists and otherwise returns 0

  • This consideration is binary.
  • This consideration works both for targets and the executing agent.
  • The target of the consideration should have the BlackBoard component for this to work.

ConstBoolConsideration

Returns a constant value. This consideration is mostly used for testing.

If isTrue is set then the trueValue is returned, otherwise the falseValue is returned.

  • This consideration is binary.
  • This consideration doesn't care about NeedTarget and targets sent to it.

InfluenceMapConsideration

This consideration searches the influence map specified for a value and returns 1 if it finds something. Otherwise it returns 0.

Because the search is heavy we optionally store the result in a blackboard Vector3 key to be used by an action. If you leave the queryResultKeyName empty then we don't store the result anywhere.

The search uses the agent/target's position as the center and takes the radius in cell count as radius. The search condition and value has to be specified as well. For example if searchCondition is set to greater and searchValue to 0.3 then if a cell with values higher than 0.3 is found in the area noted by the radius and agent/target's position on the map, the consideration returns 1 and the map coordinates of the cell are stored in the blackboard key.

  • This consideration is binary.
  • This consideration works both with and without targets. The thing that targets effect is the center point of the search.
  • The consideration only returns valid scores for SmartObjects if you set useNearestSlotPosition.

SmartObjectDistanceConsideration

Returns the distance to a target which is a smart object. You can choose to get the distance to a specific slot with a specific condition like the distance to the closes slot which is free.

If you check the box for useNearestSlotPosition then the consideration works only if the target is a smart object. The slotStatus allows you to ask for any slot's position or a slot which is free/owned by you.

For example if you choose FreeOrOwned then the distance to the closes slot which is either free or owned by the executing agent is returned.

As other distance considerations, this can be calculated on the XZ plane and can be inverted. Also the distance score is effected by minRange and maxRange so if you want to give a score of 1 to distances higher than 50 meters then maxRange should be 50. In this case 60 meters will return 1, 25 meters will return 0.5 and 10 meters returns 0.2. You should check inverse if you want 10 meters return 0.8 and 0 meters return 1 and 50 meters and above return 0.

  • This consideration is continuous.
  • This consideration is only meaningful with NeedTarget set to true and without targets always returns 0.
  • The consideration only returns valid scores for SmartObjects if you set useNearestSlotPosition.

TargetDistanceConsideration

Returns the distance to a target. This normalizes to a value between 0 and 1 based on minRange and maxRange values so their value is extremely important for this to be meaningful.

If you want your score to check for distances less than 100 meters then you need to set maxValue to 100 so the consideration returns 1 for 100 meters away and greater. It will return 0.75 for 75 meters and so on. You can invert the consideration by checking inverse so it returns 1 for 0 meters and 0 for 100 meters and 0.25 for 75 meters.

  • This consideration is continuous.
  • This consideration is only meaningful with NeedTarget set to true and without targets always returns 0.

ValidGameObjectPathConsideration

This consideration returns 1 if a valid path from the agent's NavmeshAgent to the position of the GameObject stored in the key is present, otherwise returns 0. The NeedTarget causes the GameObject to be read from the target but always a path from the owning agent is calculated. So you can check if your agent has a valid path to a position which a target specifies but you cannot check if that target has a valid path to somewhere.

  • This consideration is binary.
  • This consideration works both for targets and the executing agent but only the reading of the vector3 happens on targets and the path is calculated for the agent itself anyways.
  • The agent with the action owning this should have a NavMeshAgent component attached. The target of the consideration should have the BlackBoard component for this to work.

ValidPathConsideration

This consideration returns 1 if a valid path from the agent's NavmeshAgent to the position stored in the Vector3 key is present, otherwise returns 0. The NeedTarget causes the vector3 to be read from the target but always a path from the owning agent is calculated. So you can check if your agent has a valid path to a position which a target specifies but you cannot check if that target has a valid path to somewhere.

  • This consideration is binary.
  • This consideration works both for targets and the executing agent but only the reading of the vector3 happens on targets and the path is calculated for the agent itself anyways.
  • The agent with the action owning this should have a NavMeshAgent component attached. The target of the consideration should have the BlackBoard component for this to work.