Updated Interaction.cpp
Fixed the game crashing if there isnt any WBP inputted in tempchar
This commit is contained in:
parent
808b567d6f
commit
4fa9ca74dd
@ -31,9 +31,16 @@ void AInteraction::Tick(float DeltaTime)
|
||||
|
||||
void AInteraction::OnInteract()
|
||||
{
|
||||
CurrentWidget = CreateWidget<UUserWidget>(GetWorld(), Widget);
|
||||
CurrentWidget->AddToViewport(0);
|
||||
//handles the widget dissapearing from the viewport
|
||||
ShopDialogWidget = CreateWidget<UUserWidget>(GetWorld(), ShopDialog);
|
||||
if (ShopDialogWidget == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
ShopDialogWidget->AddToViewport(0);
|
||||
}
|
||||
//handles the widget disappearing from the viewport
|
||||
FTimerHandle WidgetTimer;
|
||||
GetWorldTimerManager().SetTimer(WidgetTimer, this, &AInteraction::RemoveWidget, WaitTimer, false);
|
||||
|
||||
@ -42,7 +49,15 @@ void AInteraction::OnInteract()
|
||||
void AInteraction::RemoveWidget()
|
||||
{
|
||||
bisDisabled = true;
|
||||
CurrentWidget->RemoveFromViewport();
|
||||
ShopDialogWidget->RemoveFromViewport();
|
||||
UE_LOG(LogTemp, Display, TEXT("setting isDisabled to true"));
|
||||
|
||||
ItemSelectorWidget = CreateWidget<UUserWidget>(GetWorld(), ItemSelector);
|
||||
if (ItemSelectorWidget == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemSelectorWidget->AddToViewport(0);
|
||||
}
|
||||
}
|
@ -24,13 +24,20 @@ public:
|
||||
virtual void Tick(float DeltaTime) override;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
TSubclassOf<UUserWidget> Widget;
|
||||
TSubclassOf<UUserWidget> ShopDialog;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
TSubclassOf<UUserWidget> ItemSelector;
|
||||
|
||||
virtual void OnInteract();
|
||||
|
||||
virtual void RemoveWidget();
|
||||
|
||||
UPROPERTY()
|
||||
UUserWidget* CurrentWidget;
|
||||
UUserWidget* ShopDialogWidget;
|
||||
|
||||
UPROPERTY()
|
||||
UUserWidget* ItemSelectorWidget;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
float WaitTimer = 8.0f;
|
||||
|
Loading…
Reference in New Issue
Block a user