> For the complete documentation index, see [llms.txt](https://espergames.gitbook.io/feel-speak/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://espergames.gitbook.io/feel-speak/scripting/speaker.md).

# Speaker

Scripting with the Speaker class.

The Speaker class represents a character in the game world that can speak.

## Notes

* All properties visible in the inspector are available through code.

## Accessing Speakers

The Speaker class keeps track of all speakers currently in the scene by updating the static `speakers` field as they are added or removed.

To get a specific Speaker, use the FeelSpeak.FindSpeaker method and pass either a character ID (`int`), character name (`string`), or the `Character` reference itself.

```csharp
Speaker mySpeaker = FeelSpeak.FindSpeaker("My Speaker");
```

## Interacting With Speakers

There are multiple methods you can use to interact with `Speaker`s. Interacting with speakers will simply trigger dialogue with them if they have a dialogue graph set. Note that you must have speakers [set up properly for your game](/feel-speak/components/speaker.md).

First of all, you may want to let Feel Speak know which `Speaker` is the player. This will help with interaction with NPC speakers.

```csharp
FeelSpeak.activePlayerSpeaker = myPlayerSpeaker;
```

If you're using the [Feel Speak Initializer](/feel-speak/components/feel-speak-initializer.md) component, it may not be necssary to do this manually through code.

### Interact With Closest

`FeelSpeak.InteractWithClosestSpeaker` simply interacts with the closest `Speaker` that is in range of the player.

```csharp
FeelSpeak.InteractWithClosestSpeaker();
```

### Interact With Specific

You can interact with a specific `Speaker` with the `Interact` or `TriggerDialogue` methods.

```csharp
mySpeaker.Interact();
```

```csharp
mySpeaker.TriggerDialogue();
```

## Updating Dialogue

You may need to occasionally update the dialogue that characters say throughout the playthrough of your game. Simply set the `dialogue` field to a new `DialogueGraph`.

```csharp
mySpeaker.dialogue = myDialogueGraph
```

## Animations

If the `GameObject` or child `GameObject` of the `Speaker` has an `Animator` component, the `Speaker` will grab it on awake and use it to run animations set in the [Characters](/feel-speak/editors/object-manager/characters.md) or [Emotions](/feel-speak/editors/object-manager/emotions.md) tabs.
