AIPerceptionConfig

Type description and basic instructions.

Description

AIPerceptionConfig is base abstract class for all perception configs such as SightConfig.

Perception configs are used to imitate different senses of AI agents.

To create a custom perception config you should inherit from AIPerceptionConfig class and implement logic that is described below.

OnTargetUpdated

When inheriting from AIPerceptionConfig you have to override OnTargetUpdated event.

public class ExamplePerceprionConfig : AIPerceptionConfig
{
    public override event Action<AIPerceptionSource> OnTargetUpdated;
}
  • OnTargetUpdated gets called when perception config has updated the target.

Initialize

When inheriting from AIPerceptionConfig you can override Initialize method.

public class ExamplePerceprionConfig : AIPerceptionConfig
{
    public override event Action<AIPerceptionSource> OnTargetUpdated;
    
    public override void Initialize(AIPerception owner)
    {
        base.Initialize(owner);
    }
}
  • Initialize gets called once when initializing config.

  • Paremeter "owner" is a reference of AI perception owner.

OnStart

When inheriting from AIPerceptionConfig you can override OnStart method.

public class ExamplePerceprionConfig : AIPerceptionConfig
{
    public override event Action<AIPerceptionSource> OnTargetUpdated;
    
    protected override void OnStart()
    {
        base.OnStart();
    }
}
  • OnStart gets called on the frame when a script is enabled, just before any of the Update methods are called the first time.

OnUpdate

When inheriting from AIPerceptionConfig you can override OnUpdate method.

public class ExamplePerceprionConfig : AIPerceptionConfig
{
    public override event Action<AIPerceptionSource> OnTargetUpdated;
    
    protected override void OnUpdate()
    {
        base.OnUpdate();
    }
}
  • OnUpdate gets called every frame, if the MonoBehaviour is enabled.

OnStop

When inheriting from AIPerceptionConfig you can override OnStop method.

public class ExamplePerceprionConfig : AIPerceptionConfig
{
    public override event Action<AIPerceptionSource> OnTargetUpdated;
    
    protected override void OnStop()
    {
        base.OnStop();
    }
}
  • OnStop gets called when the config becomes destroyed.

Last updated