# Catching Tap Count

The Ultimate Joystick has many different Events that can be subscribed to with custom functionality for your players. The two events that can be used for detecting taps on the joystick are: OnTapAchieved and OnTapReleased. Below I will show very simple examples of how to subscribe to these functions.

## OnTapAcheived

#### OnTapAchieved Event

The `OnTapAchieved` event is one of the interactive events provided by the Ultimate Joystick component. This event is triggered when the player taps the joystick successfully. The `tapCount` parameter in the event's signature indicates the number of consecutive taps the player has made on the joystick, allowing you to react differently based on the tap count if needed.

To subscribe to the `OnTapAchieved` event, you can attach a custom function that defines what should happen when the event is fired. Here's a simple example of how to subscribe to the `OnTapAchieved` event and log a message to the console:

```csharp
// Subscribe to the OnTapAchieved event
UltimateJoystick.OnTapAchieved += ( tapCount ) =>
{
    // Custom functionality goes here
    Debug.Log($"Joystick tapped { tapCount } times!");
};
```

In this example, whenever the `OnTapAchieved` event is triggered, the attached anonymous function is called, logging a message indicating the number of times the joystick was tapped.

## OnTapReleased

**OnTapReleased Event**

The OnTapReleased event is another interactive feature of the Ultimate Joystick. It is triggered when the player releases a tap on the joystick within a predefined time window. This can be useful for registering tap-and-hold actions or differentiating between tap types.

To hook into the OnTapReleased event, you simply need to subscribe a function that specifies the desired behavior upon the event's invocation. The example below demonstrates how you can subscribe to the OnTapReleased event and output a message to the console confirming the action:

```csharp
// Subscribe to the OnTapReleased event
UltimateJoystick.OnTapReleased += () =>
{
    // Custom functionality goes here
    Debug.Log( "Joystick tap released within the time window!" );
};
```

With this code snippet, whenever the OnTapReleased event occurs—signifying the end of a tap within the Tap Decay Rate—a logged message will inform you that the joystick tap has been released within the time window.


---

# 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.tankandhealerstudio.com/assets/ultimatejoystick/tips-and-tricks/catching-tap-count.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.
