> For the complete documentation index, see [llms.txt](https://malbersanimations.gitbook.io/animal-controller/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://malbersanimations.gitbook.io/animal-controller/scriptable-architecture/scriptables/mevent-listener.md).

# MEvent Listener

Last updated AC v1.5.3

## Overview

The MEvent Listener Component is a List of [**MEvents** ](/animal-controller/scriptable-architecture/scriptables/mevents.md)**Assets.**

It uses Unity Events to send the data received by each [**MEvent** ](/animal-controller/scriptable-architecture/scriptables/mevents.md)to all the components attached to a gameObject.

Is heavily based on the Talk about [**Scriptable Architecture**](https://www.youtube.com/watch?v=raQ3iHhE_Kk) by Ryan Ripple

![](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lzhr1XSMzMqNXjRnNlb%2F-M-AguhiUS1kYzc-E-hs%2F-M-AuDg7mHTnkkhouAi7%2Fimage.png?alt=media\&token=723eca33-dda5-4018-9b49-7911f9f0cba7)

{% hint style="danger" %}
**IMPORTANT:** Events on the List should **NOT** repeat
{% endhint %}

## Properties

![](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lzhr1XSMzMqNXjRnNlb%2F-M0TBGWQPTbp3eyKE-sr%2F-M0TdCdLxLdhZ-se2ETe%2Fimage.png?alt=media\&token=ebc6ca82-6028-47c6-8508-2562eb5e171e)

When a **MEvent** is selected on the list it will show the Description of the [**MEvent**](/animal-controller/scriptable-architecture/scriptables/mevents.md) on a Green Help Box. You will also gain access to the different type of Responses.

## Owner Filter

The Owner Filter lets one listener ignore invocations that were raised by somebody else. It uses the event's Sender, so the object that raises the event must call `SetSender()` on the MEvent first.

The filter applies to every entry on the component. Entries can opt out one by one.

\[Insert Image - Owner Filter fields on the MEvent Listener]

#### Filter Mode

How the Sender is checked against the Owner.

* `Ignore`: no filtering. The listener responds to every invocation. This is the default.
* `MustMatch`: the listener responds only when the Sender belongs to the Owner.
* `MustNotMatch`: the listener responds only when the Sender does **not** belong to the Owner.

When the Filter Mode is `Ignore` the Owner and Match Hierarchy fields are hidden.

#### Owner

The owner this listener belongs to. It is a Transform Reference, so it accepts a scene Transform or a `TransformVar` asset.

If the Owner is empty, or the event has no Sender, the check never matches. With `MustMatch` the listener stays silent, with `MustNotMatch` it always responds.

You can also set the Owner from code with `SetOwner(Transform)`. That runtime override wins over the Owner field, which is useful when a spawner creates the listener and binds it to a player.

#### Match Hierarchy

On: the Sender matches when it shares the same hierarchy as the Owner, so any child bone or weapon of the owner counts as the owner. Off: the Sender must be the exact same Transform.

{% hint style="info" %}
**Use case: per-player UI in local multiplayer.**

One MEvent asset can drive the UI of every player. Whoever raises the event calls `SetSender()` on it first, passing itself. Each player's UI listener sets its Filter Mode to `MustMatch` and its Owner to that player.

When Player 1 raises the event, only Player 1's UI responds. Player 2's listener skips it. You do not need one MEvent asset per player.
{% endhint %}

### Void Response

Receive an void value from the event.

### Bool Response

Receive an bool value from the event.

### Float Response

Receive an float value from the event.

### Int Response

Receive an integer value from the event.

#### Use Advanced Integer

By enabling this option the Int Comparer list will be showed. That way you can response to an specific value of the Integer value sent by the event.

![](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lzhr1XSMzMqNXjRnNlb%2F-M0TfB6kFhyJkLtQTzaU%2F-M0TfnksxldPx53wfSm2%2Fimage.png?alt=media\&token=6a1daa94-2e5f-453c-bf87-59154cab57d7)

### String Response

Receive an string value from the event.

### GameObject(GO) Response

Receive an gameObject value from the event.

### Transform (T) Response

Receive an Transform value from the event.

### Vector3 (V3) Response

Receive an Vector3 value from the event.

### Vector2 (V2) Response

Receive an Vector2 value from the event.

### Sender Response

Fires the object that raised the event, resolved to a Transform, when this entry responds.

It requires the raiser to have called `SetSender()` on the MEvent. Otherwise it fires null.

The Sender Response fires before the other responses of the entry, and it fires even when the entry's own response type is disabled.

#### Ignore Owner Filter

This entry always responds, bypassing the component's Owner Filter. The toggle only shows when the Filter Mode is not `Ignore`.

#### Debug

Logs on the Console when the entry starts and stops listening, when it responds, and why it was skipped: the Owner Filter, a disabled entry, or a disabled response type. The log also prints the Sender name.
