Updated Interaction.cpp
Added a wait timer to close the widget once open automatically
This commit is contained in:
parent
5dce4dc603
commit
b5772a024c
BIN
Content/Blueprints/Merchant/Merchant_UI/BP_OPENDIAL.uasset
(Stored with Git LFS)
BIN
Content/Blueprints/Merchant/Merchant_UI/BP_OPENDIAL.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Levels/MerchantPrototype.umap
(Stored with Git LFS)
BIN
Content/Levels/MerchantPrototype.umap
(Stored with Git LFS)
Binary file not shown.
@ -30,7 +30,13 @@ void AInteraction::Tick(float DeltaTime)
|
|||||||
|
|
||||||
void AInteraction::OnInteract()
|
void AInteraction::OnInteract()
|
||||||
{
|
{
|
||||||
UUserWidget* spawnedWidget = CreateWidget<UUserWidget>(GetWorld(), Widget);
|
CurrentWidget = CreateWidget<UUserWidget>(GetWorld(), Widget);
|
||||||
spawnedWidget->AddToViewport(0);
|
CurrentWidget->AddToViewport(0);
|
||||||
|
FTimerHandle WidgetTimer;
|
||||||
|
GetWorldTimerManager().SetTimer(WidgetTimer, this, &AInteraction::RemoveWidget, 5.0f, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AInteraction::RemoveWidget()
|
||||||
|
{
|
||||||
|
CurrentWidget->RemoveFromViewport();
|
||||||
|
}
|
@ -27,5 +27,8 @@ public:
|
|||||||
TSubclassOf<UUserWidget> Widget;
|
TSubclassOf<UUserWidget> Widget;
|
||||||
|
|
||||||
virtual void OnInteract();
|
virtual void OnInteract();
|
||||||
|
virtual void RemoveWidget();
|
||||||
|
UPROPERTY()
|
||||||
|
UUserWidget* CurrentWidget;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user