From 52639d9af666a5af55a693bd3055edb2f1276f29 Mon Sep 17 00:00:00 2001 From: MH261677 Date: Sun, 15 Jan 2023 16:15:06 +0000 Subject: [PATCH] Updated TempCharacter.cpp, Interaction.cpp Added a function which can be called from blueprints to re-enable all input once a button is pressed Fixed interaction boolean to reset itself back to false to make it so player can talk to NPC again without having to restart the game to interact with it. --- .../MerchantInteraction/Interaction.cpp | 1 + .../PlayerTemp/TempCharacter.cpp | 17 ++++++++++++++++- .../PlayerTemp/TempCharacter.h | 3 +++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp b/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp index 5cb2b8a..27c894f 100644 --- a/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp +++ b/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp @@ -59,5 +59,6 @@ void AInteraction::RemoveWidget() else { ItemSelectorWidget->AddToViewport(0); + bisDisabled = false; } } \ No newline at end of file diff --git a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp index 7c09f12..9a8920b 100644 --- a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp +++ b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp @@ -124,8 +124,21 @@ void ATempCharacter::LineTraceLogic() void ATempCharacter::InputDisabler() { UE_LOG(LogTemp, Display, TEXT("Disabling playermovement")); - GetWorld()->GetFirstPlayerController()->SetIgnoreLookInput(false); + GetWorld()->GetFirstPlayerController()->SetIgnoreLookInput(true); GetWorld()->GetFirstPlayerController()->SetIgnoreMoveInput(true); + GetWorld()->GetFirstPlayerController()->bShowMouseCursor = true; + GetWorld()->GetFirstPlayerController()->bEnableClickEvents = true; + GetWorld()->GetFirstPlayerController()->bEnableMouseOverEvents = true; +} + +void ATempCharacter::InputEnabler() +{ + UE_LOG(LogTemp, Display, TEXT("Enabling Inputs")); + GetWorld()->GetFirstPlayerController()->SetIgnoreLookInput(false); + GetWorld()->GetFirstPlayerController()->SetIgnoreMoveInput(false); + GetWorld()->GetFirstPlayerController()->bShowMouseCursor = false; + GetWorld()->GetFirstPlayerController()->bEnableClickEvents = false; + GetWorld()->GetFirstPlayerController()->bEnableMouseOverEvents = false; } void ATempCharacter::UseItem(class UBaseItem* Item) @@ -137,3 +150,5 @@ void ATempCharacter::UseItem(class UBaseItem* Item) } } + + diff --git a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h index 5b607c2..cc97668 100644 --- a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h +++ b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h @@ -53,5 +53,8 @@ public: //Using the item in the inventory UFUNCTION(BlueprintCallable, Category= "Items") void UseItem(class UBaseItem* Item); // Overriding the BaseItem Class + + UFUNCTION(BlueprintCallable) + void InputEnabler(); };