Added SneakMechanicTesting level

Added new level for sneak mechanic testing
This commit is contained in:
MARCEL HARA 2023-02-23 16:03:10 +00:00
parent 119b5a141a
commit ce4f3aff1f
3 changed files with 14 additions and 15 deletions

Binary file not shown.

BIN
Content/Levels/Testing/SneakMechanicTesting.umap (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -36,11 +36,13 @@ 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]);
Enemy = TEXT("Enemy"); Enemy = TEXT("Enemy");
UGameplayStatics::GetAllActorsWithTag(GetWorld(), Enemy, AIActors); UGameplayStatics::GetAllActorsWithTag(GetWorld(), Enemy, AIActors);
//stops crashing
if (ensureMsgf(AllActorsInScene.Num() > 0, TEXT("No Post Processing Volume in scene")))
{
PostProcessVolume = Cast<APostProcessVolume>(AllActorsInScene[0]);
}
Ammo = TEXT("Ammo"); Ammo = TEXT("Ammo");
} }
@ -61,14 +63,11 @@ 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>();
if (SphereComponent != nullptr) if (SphereComponent != nullptr) SphereComponent->SetSphereRadius(40.0f); //default value
{
SphereComponent->SetSphereRadius(40.0f); //default value
}
} }
} }
else else
@ -77,12 +76,9 @@ void ATempCharacter::Sneak()
for (AActor* Actor : AIActors) for (AActor* Actor : AIActors)
{ {
USphereComponent* SphereComponent = Actor->FindComponentByClass<USphereComponent>(); USphereComponent* SphereComponent = Actor->FindComponentByClass<USphereComponent>();
if (SphereComponent != nullptr) if (SphereComponent != nullptr) SphereComponent->SetSphereRadius(15.0f);
{
SphereComponent->SetSphereRadius(15.0f);
}
} }
PostProcessVolume->Settings.VignetteIntensity = 0.8f; if (PostProcessVolume != nullptr) PostProcessVolume->Settings.VignetteIntensity = 0.8f;
} }
} }