# Unlockables

**URL:** https://heroiclabs.com/docs/hiro/unreal/unlockables/
**Keywords:** unlockables, hiro
**Categories:** hiro, unreal, unlockables

---


# Unlockables

Read more about the Unlockables system in Hiro [here](../../concepts/unlockables/).

## Create a random unlockable

Create a random unlockable to assign to a slot (or overflow) unless there are no slots.

```cpp
FHiroOnUnlockablesCreate OnUnlockablesCreate;
OnUnlockablesCreate.AddDynamic(this, &AMyActor::OnUnlockablesCreate);
FOnError OnError;

HiroClient->UnlockablesCreate(Session, OnUnlockablesCreate, OnError);

void AMyActor::OnUnlockablesCreate(const FHiroUnlockablesList& UnlockablesList)
{
    UE_LOG(LogTemp, Log, TEXT("%s"), *UnlockablesList.ToJson());
}
```

## Get in progress unlockables

Get the unlockables which are currently in progress for the player.

```cpp
FHiroOnUnlockablesGet OnUnlockablesGet;
OnUnlockablesGet.AddDynamic(this, &AMyActor::OnUnlockablesGet);
FOnError OnError;

HiroClient->UnlockablesGet(Session, OnUnlockablesGet, OnError);

void AMyActor::OnUnlockablesGet(const FHiroUnlockablesList& UnlockablesList)
{
    UE_LOG(LogTemp, Log, TEXT("%s"), *UnlockablesList.ToJson());
}
```

## Start an unlock

Start the unlock timer for an unlockable in the specified slot.

```cpp
FHiroUnlockablesRequest Request;
Request.InstanceId = TEXT("unlockable_instance_1");

FHiroOnUnlockablesUnlockStart OnUnlockablesUnlockStart;
OnUnlockablesUnlockStart.AddDynamic(this, &AMyActor::OnUnlockablesUnlockStart);
FOnError OnError;

HiroClient->UnlockablesUnlockStart(Session, Request, OnUnlockablesUnlockStart, OnError);

void AMyActor::OnUnlockablesUnlockStart(const FHiroUnlockablesList& UnlockablesList)
{
    UE_LOG(LogTemp, Log, TEXT("%s"), *UnlockablesList.ToJson());
}
```

## Purchase an unlockable

Purchase an unlockable with soft currency based on the remainder cost calculated by the offset left to wait.

```cpp
FHiroOnUnlockablesPurchaseUnlock Request;
Request.InstanceId = TEXT("unlockable_instance_1");

FHiroOnUnlockablesPurchaseUnlock OnUnlockablesPurchaseUnlock;
OnUnlockablesPurchaseUnlock.AddDynamic(this, &AMyActor::OnUnlockablesPurchaseUnlock);
FOnError OnError;

HiroClient->UnlockablesPurchaseUnlock(Session, Request, OnUnlockablesPurchaseUnlock, OnError);

void AMyActor::OnUnlockablesPurchaseUnlock(const FHiroUnlockablesList& UnlockablesList)
{
    UE_LOG(LogTemp, Log, TEXT("%s"), *UnlockablesList.ToJson());
}
```

## Purchase a new unlockable slot

Purchase a new slot to be used to store unlockables.

```cpp
FHiroOnUnlockablesPurchaseSlot OnUnlockablesPurchaseSlot;
OnUnlockablesPurchaseSlot.AddDynamic(this, &AMyActor::OnUnlockablesPurchaseSlot);
FOnError OnError;

HiroClient->UnlockablesPurchaseSlot(Session, OnUnlockablesPurchaseSlot, OnError);

void AMyActor::OnUnlockablesPurchaseSlot(const FHiroUnlockablesList& UnlockablesList)
{
    UE_LOG(LogTemp, Log, TEXT("%s"), *UnlockablesList.ToJson());
}
```

## Claim an unlockable

Claim an unlockable whose start timer has completed or completion was fast tracked with a purchase.

```cpp
FHiroUnlockablesRequest Request;
Request.InstanceId = TEXT("unlockable_instance_1");

FHiroOnUnlockablesClaim OnUnlockablesClaim;
OnUnlockablesClaim.AddDynamic(this, &AMyActor::OnUnlockablesClaim);
FOnError OnError;

HiroClient->UnlockablesClaim(Session, Request, OnUnlockablesClaim, OnError);

void AMyActor::OnUnlockablesClaim(const FHiroUnlockablesReward& UnlockablesReward)
{
    UE_LOG(LogTemp, Log, TEXT("%s"), *UnlockablesReward.ToJson());
}
```