Website powered by

How did I deal with… writing a function telling you when you have only one item left

The BP in the image tells the UI that the player has only one item left (Items = TotalItems – 1) and sends a message via Event Dispatcher. Once the prototype proves to be functional in Unreal Engine, I’m writing the C++ version as a delegate in the Source file in Player Character, Interact function:

if (CollectedItems == (TotalItems - 1))
{
Interact_OneToGo.Broadcast();
}

This is the delegate definition in the header, triggering an event that pushes text changes in the UI Hints Panel:

DECLARE_DYNAMIC_MULTICAST_DELEGATE(FHint);

UPROPERTY(BlueprintAssignable)
FHint Interact_OneToGo;

Here you can find out about the context of this method: https://www.3dartviz.com/skills/skills-tech/programming-video-game-interaction-cpp.html#oneItemLeft

The counter triggers this Event Dispatcher when it reaches TotalItems –1, updating the UI.

The counter triggers this Event Dispatcher when it reaches TotalItems –1, updating the UI.