> For the complete documentation index, see [llms.txt](https://puzzlesystem.gitbook.io/project/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://puzzlesystem.gitbook.io/project/manual/cores/handler.md).

# CorePuzzleHandler

{% hint style="info" %}
This is the core class for the **Handler** elements. This means that the subclasses of this component also have all properties and methods that are present in here. Make use of it.
{% endhint %}

## Default

{% hint style="warning" %}
A default class of type Puzzle Handler. See *Beginning -> Puzzle Structure* for more info.
{% endhint %}

As it is has been described, this class is responsible for handling critical events of the puzzle lifespan: on puzzle solved and on puzzle failed.

![](https://2204884292-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LWSZAoTb0akZrStcZ8k%2F-LWc7LvNyirFqGIVZ-WK%2F-LWc7O6IixRm8JnMm-Gq%2FScreenshot%202019-01-19%20at%2023.00.44.png?alt=media\&token=1ad0acd2-de7c-401c-ac53-ef202d27b515)

To make your life easier, these events are easily assignable in the inspector view. Click '+' under the desired event, then select the object that you want to affect. Afterwards, in the appeared dropdown menu, choose the action that you want to apply to the object.

{% hint style="info" %}
For example, it is common to choose *GameObject -> SetActive* method in order to activate or deactivate the chosen object. So, if you have chosen *OnSolutionEvent* and *SetActive* with checked checkbox, the object will be activated as soon as the puzzle is solved.
{% endhint %}

{% hint style="info" %}
More about Unity Events: [Video Tutorial](https://youtu.be/mC_yUEnGQXM)​
{% endhint %}

The class also declares a boolean property "*debug*" that will define whether or not, this specific puzzle system -- handler, logic and triggers within one puzzle -- will debug all logs into the console.

## Inheritence

In order create more complex event callbacks, you can inherit *CorePuzzleHandler.*

There are 2 virtual methods available that you can overridde as you wish:

```
/// <summary>
/// The function that is triggered whenever the player has solved the puzzle.
/// </summary>
protected virtual void OnSolution() { }

​/// <summary>
/// The function that is triggered whenever the player makes a mistake in solving the puzzle.
/// </summary>
protected virtual void OnFailure() { }​
```

​

For example,

```
public class CustomPuzzleHandler : CorePuzzleHandler
{    
    protected override void OnSolution()    
    {        
        // Insert custom event        
        Debug.Log("Puzzle is solved!");    
    }
​}
```

{% hint style="info" %}
See more about:

* [Inheritance](https://youtu.be/18f41HX2gHk)
* [Overriding](https://youtu.be/zmf6-VIv31w)
  {% endhint %}
