# NPC Speech Bubbles

NPC Speech Bubbles are world-space UI panels that float above characters and display short contextual text when the player is nearby. They provide ambient storytelling and gameplay signposting without requiring a full dialogue interaction — an NPC might say *"Have you seen the blacksmith?"* when you walk past, shift to *"Please, find my missing cart!"* once a relevant quest is active, and go silent after you've already spoken to them.

The system is built from two cooperating parts:

* **NPCSpeechBubble** — a per-NPC MonoBehaviour that owns the bubble content, proximity detection, and conditions for what text to show.
* **SpeechBubbleManager** — a scene singleton that coordinates all active bubbles, caps how many are visible at once, and handles object pooling so bubble UI instances are reused rather than instantiated and destroyed at runtime.

Text content is driven by **Text Variants** — a list of conditional text entries evaluated in priority order each time the bubble activates. Conditions can gate variants on quest state, dialogue flags, and objective progress, so the same NPC can say something different depending on where the player is in the story. If no variant condition matches, a configurable **Default Text** is shown instead.

Bubbles respond to **proximity**: each NPC defines its own activation and deactivation distances, with optional hysteresis to prevent flickering. Line-of-sight checking is also supported. The Manager enforces a global cap on how many bubbles can be visible simultaneously, prioritising the NPCs closest to the player when the limit is reached.

The detail for each component — all properties, conditions, events, and the Manager's pooling and prioritisation settings — is covered on the next pages...


---

# 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/malbers-questforge/npc-speech-bubbles.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.
