From df4499fdde805a9527a499d34d53afe382bad784 Mon Sep 17 00:00:00 2001 From: Marcel Hara Date: Thu, 16 Mar 2023 16:31:40 +0000 Subject: [PATCH] Updated TempCharacter to fix Camera issues Fixed the UI not returning after player exits the merchant. Fixed the bug where if a player jumps and interacts with the merchant and then exits the camera is stuck in the air instead of resetting properly. --- .../PlayerTemp/TempCharacter.cpp | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp index 14a79e7..7a483fa 100644 --- a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp +++ b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp @@ -219,7 +219,7 @@ void ATempCharacter::InputDisabler() { PlayerCharacter->DisableInput(GetWorld()->GetFirstPlayerController()); } - //TURNING OFF CROSSHAIR + //TURNING OFF CROSSHAIR & IMPORTANT STATS CrossHairWidget->SetVisibility(ESlateVisibility::Hidden); ImportantStatsWidget->SetVisibility(ESlateVisibility::Hidden); @@ -228,14 +228,14 @@ void ATempCharacter::InputDisabler() APlayerController* PlayerController = GetWorld()->GetFirstPlayerController(); PlayerController->SetInputMode(FInputModeUIOnly()); PlayerController->bShowMouseCursor = true; - disableTab = true; if (ThisCamera != nullptr) { - OriginalCameraLocation = ThisCamera->GetComponentLocation(); - OriginalCameraRotation = ThisCamera->GetComponentRotation(); + return; + } + else + { OriginalCameraFOV = ThisCamera->FieldOfView; - UE_LOG(LogTemp, Display, TEXT("Original Camera Location: %s"), *OriginalCameraLocation.ToString()); } } @@ -246,20 +246,27 @@ void ATempCharacter::InputEnabler() { PlayerCharacter->EnableInput(GetWorld()->GetFirstPlayerController()); } + + //TURNING ON THE CROSSHAIR AND IMPORTANTSTATS WIDGET + + CrossHairWidget->SetVisibility(ESlateVisibility::Visible); + ImportantStatsWidget->SetVisibility(ESlateVisibility::Visible); + //Reset UI Mode APlayerController* PlayerController = GetWorld()->GetFirstPlayerController(); PlayerController->SetInputMode(FInputModeGameOnly()); PlayerController->bShowMouseCursor = false; - - UE_LOG(LogTemp, Display, TEXT("Enabling Inputs")); + disableTab = true; TraceDistance = 300; if (ThisCamera != nullptr) { - ThisCamera->SetWorldLocation(OriginalCameraLocation); - ThisCamera->SetWorldRotation(OriginalCameraRotation); + return; + } + else + { ThisCamera->FieldOfView = OriginalCameraFOV; - UE_LOG(LogTemp, Display, TEXT("Original Camera Location: %s"), *OriginalCameraLocation.ToString()); + ThisCamera->ResetRelativeTransform(); } }