# Work with Loot Boxes In-Game

{% hint style="info" %}
This requires you to have set up a Loot Box in the management interface.

Please refer to the [guide on creating Loot Boxes](/content/working-with-assets/how-to/rarity-assets.md) for this
{% endhint %}

### Open Loot Box

After the player has either purchased or have been awarded a loot box they can open it.

This will remove the loot box from their inventory and grant them the item from the loot box.

To see what items were granted by the Loot box you can use the [Grant Notifications Method](/content/working-with-assets/how-to/check-grant-notifications.md)

{% tabs %}
{% tab title="Unity" %}

```csharp
int assetInstanceID = 90;
LootLockerSDKManager.OpenALootBoxForAssetInstances(assetInstanceID, (response) =>
{
    if (response.success)
    {
        Debug.Log("Successfully opened Loot box");
    }
    else
    {
        Debug.Log("Error opening Loot box");
    }
});
```

{% endtab %}

{% tab title="Unreal" %}

<figure><img src="/files/AsoNje8BL9yovYoIa3m4" alt=""><figcaption><p><a href="https://blueprintue.com/blueprint/k6sivn6t/">Blueprint example of opening a lootbox</a></p></figcaption></figure>
{% endtab %}
{% endtabs %}

### Inspect Loot Box

Before opening a Loot Box we can inspect it to see what the player may get

{% tabs %}
{% tab title="Unity" %}

```csharp
int assetInstanceID = 90;
LootLockerSDKManager.InspectALootBoxForAssetInstances(assetInstanceID, (response) =>
{
    if (response.success)
    {
        Debug.Log("Successfully inspected Loot box");
    }
    else
    {
        Debug.Log("Error inspecting Loot box");
    }
});
```

{% endtab %}

{% tab title="Unreal" %}

<figure><img src="/files/iECmPqBvXzIjKHvrqSxI" alt=""><figcaption><p><a href="https://blueprintue.com/blueprint/0v1xo_2d/">Blueprint example of inspecting a lootbox</a></p></figcaption></figure>
{% endtab %}
{% endtabs %}


---

# 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://docs.lootlocker.com/content/working-with-assets/how-to/implement-loot-box-in-game.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.
