# Custom Conditions

Creating custom **Conditions** is much like creating custom **Actions** but even easier. If you haven't taken a look at how to create **Actions** it is encourage that you do so, as the process is practically the same.

To create a custom **Condition** right-click in the *Project Panel*, select `Create → GameCreator → Condition` and give it a suitable name. Because the template file is a too simple **Condition** example, we're going to create a more complex one through this manual. We're going to create a \*\*Condition that checks whether two objects are within a certain radius.

{% hint style="success" %}
We use the convention **"Condition" +** **name**, but you can use whatever you like.
{% endhint %}

![](/files/-LB0V8Mh55rd4BIJiFxG)

A **Condition** code is divided in a *runtime* section and an *editor* section.

![](/files/-LB0VTzTpTGv65etIiCB)

The runtime section describes how it checks whether *something* is true or false. To do so, declare your properties below the class definition and override the `Check` method. To create the new **Condition** let's remove the `isSatisfied` property and create 3 others:

```csharp
public Transform objectA;
public Transform objectB;
public float maxDistance = 5.0f;
```

And finally fill the `Check()` method. To check whether `objectA` is within a distance of `maxDistance` respect `objectB` we calculate the distance between the two objects and return if the value is lower than the threshold.

```csharp
public override bool Check(GameObject target)
{
    if (this.objectA == null) return false;
    if (this.objectB == null) return false;
​
    float distance = Vector3.Distance(
        this.objectA.position,
        this.objectB.position
    );
​
    return (distance <= this.maxDistance);
}
```

{% hint style="info" %}
The *Editor* section of a **Condition** is exactly as the **Action**. Check it out clicking [here](/game-creator/systems/game-creator-api/custom-actions.md#editor-body-example).
{% endhint %}


---

# 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://docs.gamecreator.one/game-creator/systems/game-creator-api/custom-conditions.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.
