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.
This commit is contained in:
Marcel Hara 2023-03-16 16:31:40 +00:00
parent 093825dc0d
commit df4499fdde

View File

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