Bugfix No Post Processing Volume Crashes Engine
This commit is contained in:
parent
c880eb27ac
commit
985e713659
@ -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);
|
||||||
PostProcessVolume = Cast<APostProcessVolume>(AllActorsInScene[0]);
|
if (ensureMsgf(AllActorsInScene.Num() > 0, TEXT("No Post Processing Volume in scene")))
|
||||||
|
{
|
||||||
|
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()
|
||||||
{
|
{
|
||||||
@ -134,25 +135,25 @@ void ATempCharacter::LineTraceLogic()
|
|||||||
{
|
{
|
||||||
//we store the GetItem function from InventoryComponent into ItemArray variable
|
//we store the GetItem function from InventoryComponent into ItemArray variable
|
||||||
|
|
||||||
if(OutHit.GetActor() == nullptr)
|
if (OutHit.GetActor() == nullptr)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(OutHit.GetActor()->FindComponentByClass<UInventoryComponent>())
|
if (OutHit.GetActor()->FindComponentByClass<UInventoryComponent>())
|
||||||
{
|
{
|
||||||
UE_LOG(LogTemp, Display, TEXT("Hit Merchant"));
|
UE_LOG(LogTemp, Display, TEXT("Hit Merchant"));
|
||||||
auto ItemArray = OutHit.GetActor()->FindComponentByClass<UInventoryComponent>()->GetItem(0);
|
auto ItemArray = OutHit.GetActor()->FindComponentByClass<UInventoryComponent>()->GetItem(0);
|
||||||
if(GoldBalance >= ItemArray->ItemCostPrice)
|
if (GoldBalance >= ItemArray->ItemCostPrice)
|
||||||
{
|
{
|
||||||
GoldBalance -= ItemArray->ItemCostPrice;
|
GoldBalance -= ItemArray->ItemCostPrice;
|
||||||
Inventory->AddItem(ItemArray);
|
Inventory->AddItem(ItemArray);
|
||||||
UE_LOG(LogTemp, Display, TEXT("Item Purchased"));
|
UE_LOG(LogTemp, Display, TEXT("Item Purchased"));
|
||||||
}
|
}
|
||||||
if(GoldBalance <= 0)
|
if (GoldBalance <= 0)
|
||||||
{
|
{
|
||||||
UE_LOG(LogTemp, Display, TEXT("Not Enough Gold"));
|
UE_LOG(LogTemp, Display, TEXT("Not Enough Gold"));
|
||||||
}
|
}
|
||||||
if(OutHit.GetActor()->ActorHasTag(Ammo))
|
if (OutHit.GetActor()->ActorHasTag(Ammo))
|
||||||
{
|
{
|
||||||
OutHit.GetActor()->Destroy();
|
OutHit.GetActor()->Destroy();
|
||||||
}
|
}
|
||||||
@ -244,7 +245,7 @@ void ATempCharacter::InputEnabler()
|
|||||||
|
|
||||||
void ATempCharacter::UseItem(class UBaseItem* Item)
|
void ATempCharacter::UseItem(class UBaseItem* Item)
|
||||||
{
|
{
|
||||||
if(Item)
|
if (Item)
|
||||||
{
|
{
|
||||||
Item->Use(this);
|
Item->Use(this);
|
||||||
Item->OnUse(this); //OnUse is a Blueprint Version
|
Item->OnUse(this); //OnUse is a Blueprint Version
|
||||||
@ -257,7 +258,3 @@ void ATempCharacter::BuyItem()
|
|||||||
TraceDistance = 1000;
|
TraceDistance = 1000;
|
||||||
LineTraceLogic();
|
LineTraceLogic();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user