Bugfix No Post Processing Volume Crashes Engine

This commit is contained in:
Philip W 2023-02-23 01:28:29 +00:00
parent c880eb27ac
commit 985e713659

View File

@ -22,7 +22,6 @@ ATempCharacter::ATempCharacter()
GoldBalance = GoldBalance; GoldBalance = GoldBalance;
Health = Health; Health = Health;
this->GetCharacterMovement()->GetNavAgentPropertiesRef().bCanCrouch = true; this->GetCharacterMovement()->GetNavAgentPropertiesRef().bCanCrouch = true;
} }
// Called when the game starts or when spawned // Called when the game starts or when spawned
@ -36,7 +35,10 @@ void ATempCharacter::BeginPlay()
//MAKE SURE POST PROCESSING IS IN THE SCENE OR GAME WILL CRASH //MAKE SURE POST PROCESSING IS IN THE SCENE OR GAME WILL CRASH
UGameplayStatics::GetAllActorsOfClass(GetWorld(), APostProcessVolume::StaticClass(), AllActorsInScene); UGameplayStatics::GetAllActorsOfClass(GetWorld(), APostProcessVolume::StaticClass(), AllActorsInScene);
if (ensureMsgf(AllActorsInScene.Num() > 0, TEXT("No Post Processing Volume in scene")))
{
PostProcessVolume = Cast<APostProcessVolume>(AllActorsInScene[0]); PostProcessVolume = Cast<APostProcessVolume>(AllActorsInScene[0]);
}
Enemy = TEXT("Enemy"); Enemy = TEXT("Enemy");
UGameplayStatics::GetAllActorsWithTag(GetWorld(), Enemy, AIActors); UGameplayStatics::GetAllActorsWithTag(GetWorld(), Enemy, AIActors);
@ -49,6 +51,7 @@ void ATempCharacter::ForwardInput(float Axis)
{ {
AddMovementInput(UKismetMathLibrary::GetForwardVector(FRotator(0, GetControlRotation().Yaw, 0)) * Axis); AddMovementInput(UKismetMathLibrary::GetForwardVector(FRotator(0, GetControlRotation().Yaw, 0)) * Axis);
} }
//Binds the input we made in the setup player component to the right vector //Binds the input we made in the setup player component to the right vector
void ATempCharacter::RightMoveInput(float Axis) void ATempCharacter::RightMoveInput(float Axis)
{ {
@ -61,7 +64,7 @@ void ATempCharacter::Sneak()
if (bIsCrouched) if (bIsCrouched)
{ {
UnCrouch(); UnCrouch();
PostProcessVolume->Settings.VignetteIntensity = 0.0f; if (PostProcessVolume != nullptr) PostProcessVolume->Settings.VignetteIntensity = 0.0f;
for (AActor* Actor : AIActors) for (AActor* Actor : AIActors)
{ {
USphereComponent* SphereComponent = Actor->FindComponentByClass<USphereComponent>(); USphereComponent* SphereComponent = Actor->FindComponentByClass<USphereComponent>();
@ -82,9 +85,8 @@ void ATempCharacter::Sneak()
SphereComponent->SetSphereRadius(15.0f); SphereComponent->SetSphereRadius(15.0f);
} }
} }
PostProcessVolume->Settings.VignetteIntensity = 0.8f; if (PostProcessVolume != nullptr) PostProcessVolume->Settings.VignetteIntensity = 0.8f;
} }
} }
@ -115,7 +117,6 @@ void ATempCharacter::KeyPressed()
} }
// Line trace logic // Line trace logic
void ATempCharacter::LineTraceLogic() void ATempCharacter::LineTraceLogic()
{ {
@ -257,7 +258,3 @@ void ATempCharacter::BuyItem()
TraceDistance = 1000; TraceDistance = 1000;
LineTraceLogic(); LineTraceLogic();
} }