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