> For the complete documentation index, see [llms.txt](https://renownedgames.gitbook.io/ai-tree/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://renownedgames.gitbook.io/ai-tree/api/runtime/aiperceptionconfig.md).

# AIPerceptionConfig

### 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.

<pre class="language-csharp"><code class="lang-csharp"><strong>public class ExamplePerceprionConfig : AIPerceptionConfig
</strong>{
    public override event Action&#x3C;AIPerceptionSource> OnTargetUpdated;
}
</code></pre>

* OnTargetUpdated gets called when perception config has updated the target.

### Initialize

When inheriting from AIPerceptionConfig you can override Initialize method.

<pre class="language-csharp"><code class="lang-csharp"><strong>public class ExamplePerceprionConfig : AIPerceptionConfig
</strong>{
    public override event Action&#x3C;AIPerceptionSource> OnTargetUpdated;
    
<strong>    public override void Initialize(AIPerception owner)
</strong>    {
        base.Initialize(owner);
    }
}
</code></pre>

* Initialize gets called once when initializing config.&#x20;
* Paremeter "owner" is a reference of AI perception owner.

### OnStart

When inheriting from AIPerceptionConfig you can override OnStart method.

<pre class="language-csharp"><code class="lang-csharp"><strong>public class ExamplePerceprionConfig : AIPerceptionConfig
</strong>{
    public override event Action&#x3C;AIPerceptionSource> OnTargetUpdated;
    
    protected override void OnStart()
    {
        base.OnStart();
    }
}
</code></pre>

* 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.

<pre class="language-csharp"><code class="lang-csharp"><strong>public class ExamplePerceprionConfig : AIPerceptionConfig
</strong>{
    public override event Action&#x3C;AIPerceptionSource> OnTargetUpdated;
    
    protected override void OnUpdate()
    {
        base.OnUpdate();
    }
}
</code></pre>

* OnUpdate gets called every frame, if the MonoBehaviour is enabled.

### OnStop

When inheriting from AIPerceptionConfig you can override OnStop method.

<pre class="language-csharp"><code class="lang-csharp"><strong>public class ExamplePerceprionConfig : AIPerceptionConfig
</strong>{
    public override event Action&#x3C;AIPerceptionSource> OnTargetUpdated;
    
    protected override void OnStop()
    {
        base.OnStop();
    }
}
</code></pre>

* OnStop gets called when the config becomes destroyed.
