Bugfix Null Cached AI References

This commit is contained in:
Philip W 2023-03-06 15:37:31 +00:00
parent 6db0770582
commit da1b3e9137

View File

@ -39,7 +39,7 @@ void ATempCharacter::BeginPlay()
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);
Ammo = TEXT("Ammo"); Ammo = TEXT("Ammo");
NoiseEmitter = Cast<UPawnNoiseEmitterComponent>(this->FindComponentByClass(UPawnNoiseEmitterComponent::StaticClass())); NoiseEmitter = Cast<UPawnNoiseEmitterComponent>(this->FindComponentByClass(UPawnNoiseEmitterComponent::StaticClass()));
} }
@ -66,27 +66,27 @@ void ATempCharacter::Sneak()
UnCrouch(); UnCrouch();
isInStealth = false; isInStealth = false;
if (PostProcessVolume != nullptr) 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>();
if (IsValid(SphereComponent)) // if (IsValid(SphereComponent))
{ // {
SphereComponent->SetSphereRadius(40.0f); //default value // SphereComponent->SetSphereRadius(40.0f); //default value
} // }
} //}
} }
else else
{ {
Crouch(); Crouch();
isInStealth = true; isInStealth = true;
for (AActor* Actor : AIActors) /*for (AActor* Actor : AIActors)
{ {
USphereComponent* SphereComponent = Actor->FindComponentByClass<USphereComponent>(); USphereComponent* SphereComponent = Actor->FindComponentByClass<USphereComponent>();
if (IsValid(SphereComponent)) if (IsValid(SphereComponent))
{ {
SphereComponent->SetSphereRadius(5.0f); SphereComponent->SetSphereRadius(5.0f);
} }
} }*/
if (PostProcessVolume != nullptr) PostProcessVolume->Settings.VignetteIntensity = 0.8f; if (PostProcessVolume != nullptr) PostProcessVolume->Settings.VignetteIntensity = 0.8f;
} }
} }