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()
|
void AInteraction::OnInteract()
|
||||||
{
|
{
|
||||||
CurrentWidget = CreateWidget<UUserWidget>(GetWorld(), Widget);
|
ShopDialogWidget = CreateWidget<UUserWidget>(GetWorld(), ShopDialog);
|
||||||
CurrentWidget->AddToViewport(0);
|
if (ShopDialogWidget == nullptr)
|
||||||
//handles the widget dissapearing from the viewport
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ShopDialogWidget->AddToViewport(0);
|
||||||
|
}
|
||||||
|
//handles the widget disappearing from the viewport
|
||||||
FTimerHandle WidgetTimer;
|
FTimerHandle WidgetTimer;
|
||||||
GetWorldTimerManager().SetTimer(WidgetTimer, this, &AInteraction::RemoveWidget, WaitTimer, false);
|
GetWorldTimerManager().SetTimer(WidgetTimer, this, &AInteraction::RemoveWidget, WaitTimer, false);
|
||||||
|
|
||||||
@ -42,7 +49,15 @@ void AInteraction::OnInteract()
|
|||||||
void AInteraction::RemoveWidget()
|
void AInteraction::RemoveWidget()
|
||||||
{
|
{
|
||||||
bisDisabled = true;
|
bisDisabled = true;
|
||||||
CurrentWidget->RemoveFromViewport();
|
ShopDialogWidget->RemoveFromViewport();
|
||||||
UE_LOG(LogTemp, Display, TEXT("setting isDisabled to true"));
|
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;
|
virtual void Tick(float DeltaTime) override;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere)
|
UPROPERTY(EditAnywhere)
|
||||||
TSubclassOf<UUserWidget> Widget;
|
TSubclassOf<UUserWidget> ShopDialog;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere)
|
||||||
|
TSubclassOf<UUserWidget> ItemSelector;
|
||||||
|
|
||||||
virtual void OnInteract();
|
virtual void OnInteract();
|
||||||
|
|
||||||
virtual void RemoveWidget();
|
virtual void RemoveWidget();
|
||||||
|
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
UUserWidget* CurrentWidget;
|
UUserWidget* ShopDialogWidget;
|
||||||
|
|
||||||
|
UPROPERTY()
|
||||||
|
UUserWidget* ItemSelectorWidget;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere)
|
UPROPERTY(EditAnywhere)
|
||||||
float WaitTimer = 8.0f;
|
float WaitTimer = 8.0f;
|
||||||
|
Loading…
Reference in New Issue
Block a user