Skip to content

Target Filters

Different decisions have different targets, so we need a way to filter targets for each decision to ensure that only the appropriate targets are evaluated. This is the purpose of Target Filters. If a decision has no targets, then target filters are not required.

The final targets of a decision are the intersection of all filtered targets returned by its target filters.

center|600

Creating Target Filters

  1. To create a new target filter, define a new class that inherits from TargetFilter and override the OnFilterTarget method:

    public class ChargeStationFilter : TargetFilter
    {
        public ChargeStationType Type;
    
        protected override bool OnFilterTarget(UtilityEntity target)
        {
            return target.EntityFacade is ChargeStation station && station.Type == Type;
        }
    }
    

  2. To add the the target filter to the intelligence asset, go to the Target Filter Tab, select the target filter type, give it a name, and then click the Create button:
    Attachments/UtilityIntelligence/Documentation/UtilityIntelligence/EditorWindow/target-filter-tab.png

  3. To attach the target filter to a decision, select the decision in the Decision Tab, choose the target filter’s name, and then click the Add button:
    Attachments/UtilityIntelligence/Documentation/UtilityAgent/Decisions/attach-target-filter.png

Adding Parameter Fields

There are many cases when you need to add parameters to an target filer to customize how it filter targets. To achieve this, you need to declare these parameters as public fields in your target filters. Here an example of how to do this:

public class TeamFilter : TargetFilter
{
    public Team Team;
    protected override bool OnFilterTarget(UtilityEntity target)
    {
        if (target.EntityFacade is Character targetCharacter)
        {
            return targetCharacter.Team == this.Team;
        }

        return false;
    }
}

Built-in Target Filters

Currently, we provides these built-in target filters:

  • OtherFilter: Filters out the current agent, leaving other entities as targets.
  • AgentFilter: Filters out entities that are not utility agents, leaving only utility agents as targets.

If you haven’t already, please consider leaving a review on the Asset Store. Whether good or bad, your feedback helps shape the future of this framework, and lets others determine whether it’s a good fit for their games. Thank you so much!💘 I love you all!🥰


Last update : September 28, 2025
Created : September 1, 2024