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.
This commit is contained in:
MH261677 2023-01-15 16:15:06 +00:00
parent e7fa8f4c63
commit 52639d9af6
3 changed files with 20 additions and 1 deletions

View File

@ -59,5 +59,6 @@ void AInteraction::RemoveWidget()
else
{
ItemSelectorWidget->AddToViewport(0);
bisDisabled = false;
}
}

View File

@ -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)
}
}

View File

@ -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();
};