# 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 %}

![](https://2174264233-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAqwYovmUPn5V6CMeID%2F-LB0UxgVVGE7F0SFi_4r%2F-LB0V8Mh55rd4BIJiFxG%2Fapi-create-action.jpg?alt=media\&token=6c13d10b-8a08-4cdc-8f8e-910270f55dd9)

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

![](https://2174264233-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAqwYovmUPn5V6CMeID%2F-LB0UxgVVGE7F0SFi_4r%2F-LB0VTzTpTGv65etIiCB%2Fapi-condition-runtime.jpg?alt=media\&token=f23ff279-2b20-4204-b33f-783a87fd5bc0)

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](https://docs.gamecreator.one/game-creator/systems/custom-actions#editor-body-example).
{% endhint %}
