# Combo Manager

## Overview

This component uses Modes Abilities Index in the Animal Controller to create combo sequences.&#x20;

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FQsieTTMprF5PjvVEJo0g%2Fimage.png?alt=media&#x26;token=e5092f3a-104d-411c-97ba-56a14b789178" alt=""><figcaption></figcaption></figure>

## Requirements

It requires an Animal Controller component. It does not have to be in the same gameobject as the Animal script. I recommend setting this component in a Child GameObject

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FKsZvOhvEcmUcxqb3gm8f%2Fimage.png?alt=media&#x26;token=d619e570-fa87-4542-a937-45ea3fb79684" alt=""><figcaption></figcaption></figure>

## How it works

The combo manager uses Modes to play animations. It will check the right time for an Ability to play the next animation given a Branch value. The Branch value is the Input you give the character.

E.g. **Branch 0** is Left click; **Branch 1** is Right Click. You can have as many branches as you like.&#x20;

![First: Atk1 +Atk1+Atk1(0-0-0)                               Second: Atk1+Atk1+Atk2 (0-0-1)](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lzhr1XSMzMqNXjRnNlb%2F-MTgvTNYL8WBFRD_vsA8%2F-MTgwLdUSmjDQ85Hg41E%2Fmg2R4BEpeY.gif?alt=media\&token=42094af2-2087-4d5e-9e1d-c630201c0fd9)

{% hint style="info" %}
To play a combo, call the method. **`ComboManager.Play(int Branch)`**
{% endhint %}

Connect the method to your Input Provider:

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FYD1XeNeyqxIS0wTvtlkO%2Fimage.png?alt=media&#x26;token=a85a16c6-800c-4ee4-a0a9-0a4251cd569f" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}

## If you are using the [Weapon Manager](https://malbersanimations.gitbook.io/animal-controller/main-components/weapon-manager), There is no need to use the Play() method. The [Weapon Manager](https://malbersanimations.gitbook.io/animal-controller/main-components/weapon-manager) will do it automatically.

{% endhint %}

## Parameters

### Animal

Reference for the Animal Component

### Active Combo Index

Which is the current Active combo. This is used when you want to change combos if the character is unharmed, or if the character equips a weapon. The Active Combo is highlighted in yellow

![](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FOy8S3wOB3kIvcYj48JmB%2FUnity_df8htplJTP.gif?alt=media\&token=2e0b096b-a154-4271-9260-7dbc4afd7c23)

{% hint style="info" %}
If the Active Combo Index is set to -1, no combo will play. (The combo manager will be disabled
{% endhint %}

### Branch

This value holds the branching value for the combo sequences. For example: You can set the Branch Value 0 to the Mouse Left Click, and 1 for Mouse Right Click. Changing the Branch Value in the middle of a sequence allows to have different animation variations in a single Combo.&#x20;

### Disable on Sleep

If the Animal Controller is sleep, the combo manager will be disabled internally too.

## Combo List

Combos are groups of sequences that activate a new [**Mode** ](https://malbersanimations.gitbook.io/animal-controller/main-components/manimal-controller/modes)**Ability** on the Animal using the activation time of the current/Required Mode Ability.&#x20;

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2Fjv5oa5NTfyn5SfvSWxiM%2Fimage.png?alt=media&#x26;token=11e2a1d6-bc56-4a09-831b-519c87d1926c" alt=""><figcaption></figcaption></figure>

### Index

Index of the combos. Use it to set the current active Combo with the method: **`ComboManager.SetActiveCombo(int Index)`**. An example of this is when a new weapon is equipped. The active combo will change from Unarmed to Melee.

### Name

Name of the Combo. Use this value if you do not want to use the index value with the method: **`ComboManager.SetActiveCombo(string Index)`**

### Mode

The mode that will be used in the Combo.&#x20;

## Sequences

&#x20;Each sequence holds the values needed to activate the proper animation at the proper time.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FQluWpXd8MVp9umZr3j1S%2Fimage.png?alt=media&#x26;token=26dcda9a-1ffe-4f69-95d7-2fd5047904c8" alt=""><figcaption></figcaption></figure>

### **Branch**

Helps activate different sequences with different inputs.

### **Required Ability**

&#x20;Used to Identify which is the current Playing Ability on the mode.

{% hint style="success" %}
&#x20;If is set to **Zero** then the Ability is a Started Combo Sequence

Is recommended that All Combo starters are set at the top of the list. They are color coded with <mark style="color:green;">**green**</mark>**.**
{% endhint %}

### **Play Ability**

&#x20;Used to Activate an Ability on the Mode if the Required Ability is within the Activation time

### **Activation Time**

Search on the Playing Ability Animation the range in a normalized time and if you execute the Activation Combo code within that range, then the next sequence will be activated.&#x20;

### **Finisher**

Used to identify if the current playing sequence is the Finisher Animation. This is color coded as **Cyan**.

All the sequences use a mode **Ability** index to identify which Animation can be activated:

![Steve Attack Mode and its Abilities Index. E.g. Right Punch Index is 1](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lzhr1XSMzMqNXjRnNlb%2F-MTgzaaKunHhQCnSX1Mg%2F-MTh1VxDXGGrDSbd7dBo%2Fimage.png?alt=media\&token=686fe6f6-a557-4e6a-828d-79a53f40b87a)

## Events

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FWVHcQZb2WOX6E90momnl%2Fimage.png?alt=media&#x26;token=7e6ae1e4-6c17-4d7c-8063-d6bc2943dd56" alt=""><figcaption></figcaption></figure>

### On Sequence Play (Int)

Invoked when the sequence starts. the value given is (Mode ID\*1000 + Ability Value)

### On Combo Finished

Invoked when the combo played a finisher sequence

### On Combo Interrupted

Invoked when the combo played **did not** play a finisher sequence

## Functions and Methods

### `void Play(int branch)`

> Set the Branch value. and plays a combo

### `void SetActiveCombo(int Index)`

> Set the current active combo on the Manager

### `void SetBranch(int branch)`

> Set the Branch value.


---

# 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://malbersanimations.gitbook.io/animal-controller/main-components/combo-manager.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.
