> For the complete documentation index, see [llms.txt](https://plugn-play.gitbook.io/ultimate-dice-system/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://plugn-play.gitbook.io/ultimate-dice-system/blueprint-integration.md).

# Blueprint Integration

Call ThrowDice on a player's thrower and receive the RollResults interface event.

## Blueprint responsibilities

| Blueprint          | Responsibility                                                                          |
| ------------------ | --------------------------------------------------------------------------------------- |
| BP\_DiceManager    | Finds players, creates their owned throwers, and stores shared history and best scores. |
| BP\_DiceThrower    | Holds a player's settings, input, HUD, batch spawning and tracking camera.              |
| BP\_Dice           | Simulates one die, detects its face, and updates its material and result effect.        |
| BP\_DiceRollRecord | Tracks one batch until every entry resolves, then reports it once.                      |
| BPI\_Dice          | Defines the ThrowDice and RollResults interface messages.                               |
| BP\_DiceConfig     | Data Asset class used for system presets.                                               |

## Throw from another Blueprint

{% stepper %}
{% step %}

## Get the intended player's controller

Use the PlayerController associated with your interaction. In multiplayer, do not assume the first controller or first thrower belongs to the player making the request.
{% endstep %}

{% step %}

## Find and cache that player's thrower

Find `BP_DiceThrower` actors and select the one whose **Get Owner** equals that PlayerController. Cache the reference after the manager has created it. For repeated interactions, reuse a valid cached reference instead of searching every frame.
{% endstep %}

{% step %}

## Send ThrowDice to the thrower

Call **ThrowDice (Message)** from `BPI_Dice`, using the selected thrower as the Target.

The calling Blueprint does not have to implement the interface just to send a message. The **target** must implement it; `BP_DiceThrower` already does.
{% endstep %}

{% step %}

## Let the existing request flow handle the throw

The request uses the thrower's selected count, size, forced value and toggles. Its internal server RPC performs the authoritative batch spawn. Existing Can Roll, roll-lock, input-lock and selection checks still apply.
{% endstep %}
{% endstepper %}

Sending `ThrowDice` to an existing `BP_Dice` actor launches that individual die. Sending it to the player's **thrower** is the batch-spawning workflow.

## Receive completed batch results

Add `BPI_Dice` under **Class Settings → Implemented Interfaces** on an Actor Blueprint, then implement **Event RollResults**. Place or spawn an instance of that actor in the world.

The batch record calls this interface message on **all world actors implementing BPI\_Dice**. Filter by the Player Controller input if your actor is interested in a particular player.

| Input             | Type                              | Meaning                                             |
| ----------------- | --------------------------------- | --------------------------------------------------- |
| Player Controller | PlayerController object reference | The owner of the throw being reported.              |
| Dice Results      | Integer array                     | One recorded value per batch entry, in batch order. |
| Dice Score        | Integer                           | Sum of valid face values in that batch.             |

For a batch `[2, 6, 3]`, Dice Score is `11`. Use a **For Each Loop** on Dice Results to process individual dice.

## Result values

| Value | Meaning                                                                  |
| ----- | ------------------------------------------------------------------------ |
| 1–6   | A valid D6 face.                                                         |
| 0     | An invalid or unresolved face, including timeout without a valid result. |
| -1    | Still rolling; used internally while the batch is pending.               |
| -2    | A die became unavailable before its result could be recorded.            |

The completion event is sent only after no entries remain pending. Do not treat Dice Score alone as proof that the entire batch is valid: invalid entries are excluded from the sum. For a fully valid batch, check that every value is between 1 and 6.

## Network execution

**RollResults is broadcast on the server.** It is a Blueprint interface call, not a network multicast. A client-only widget does not receive it automatically, and widgets/components are not found by the actor-only interface search.

If a client UI needs a custom result notification, receive it in your server-side actor and route the permitted information through a suitable replicated actor or owning-client RPC. The included HUD already has its own presentation flow.

Private rolls still reach server-side `RollResults` listeners with their actual values. Your custom listeners must preserve privacy when forwarding or displaying those values.

## Roll-record lifetime

`BP_DiceRollRecord` retains an integer result array while its dice settle, submits the completed history row, broadcasts the result once, and destroys itself. It is a temporary batch tracker, not a persistent save-game record.

The manager is required for the current completion/reporting flow. Keep it alive for the duration of the match.
