Triggerbox and HUD helptext

I made this Triggerbox with OnOverlapBegin and OnOverlapend functions, so im planning to do is make a string variable, and when;

OnOverlapBegin function is used, the string variable will be assigned a value of “Press C to crouch” (for example) and

when Overlapend function is used, the string value will be set to none.

so in the UserWidget HUD, named PlayerHUD, i would like to get the string value of the Triggerbox and assign it to a textbox.

Your best approach to this is in the function you have bound to the OnOverlapBegin,

TriggerBox->OnComponentBeginOverlap.AddDynamic(this, &AClass::OverlapBegin);

you will want to get the HUD,

AMyHUD * hud = Cast<AMyHUD>(UGameplayStatics::GetPlayerController(this, 0)->GetHUD());

and then set the your text box value on the HUD to be ‘Press C to crouch’. Then so the same but OnOverlapEnd event.

wait so where do i put

TriggerBox->OnComponentBeginOverlap.AddDynamic(this, &AClass::OverlapBegin);
AMyHUD * hud = Cast<AMyHUD>(UGameplayStatics::GetPlayerController(this, 0)->GetHUD());
 ?

and the MyHUD should i change it to my PlayerHUD? making it

 APlayerHUD * hud = Cast<APlayerHUD>(UGameplayStatics::GetPlayerController(this, 0)->GetHUD()); ?