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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://renownedgames.gitbook.io/ai-tree/api/runtime/aiperceptionconfig.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
