# Custom Hooks

Hooks are *Unity* components that allow you to easily access unique objects such as the *Player* or the *Main Camera*. Their use is not required but useful if you want to simplify the process of selecting common objects.

{% hint style="info" %}
Let's say you want to detect when the player enters a certain area with a **Trigger**.&#x20;

Instead of setting the **Trigger** to Enter and dragging and dropping the **Player** game object into the target field, you can simply mark the `collideWithPlayer` checkbox and it automatically looks for the **Player**.
{% endhint %}

Creating a custom hook is really easy. **Game Creator** already provides a hook for some components but if you want, for example, to create one for the player's *Dragonfly*, you can create a class that inherits from `IHook` as follows:

```csharp
public class HookDragonfly : IHook<HookDragonfly> {}
```

{% hint style="warning" %}
Notice that using **Hooks** requires to use the `GameCreator.Core.Hooks` namespace
{% endhint %}

That's all. Add this component to you game object and you'll be able to access it using `HookDragonfly.Instance`.


---

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