From 43ef8e2110506dfa5c65082dfa3584dbc71d71cb Mon Sep 17 00:00:00 2001 From: MH261677 Date: Fri, 17 Feb 2023 13:12:28 +0000 Subject: [PATCH] Updated TempCharacter to sneak functionality Added sneak functionality which makes the sphere radius smaller near enemies. --- Config/DefaultEngine.ini | 12 +++++++ Content/Levels/Top_layer_level.umap | 2 +- .../PlayerTemp/TempCharacter.cpp | 32 ++++++++++++------- .../PlayerTemp/TempCharacter.h | 1 - 4 files changed, 34 insertions(+), 13 deletions(-) diff --git a/Config/DefaultEngine.ini b/Config/DefaultEngine.ini index b792816..f3f6b2f 100644 --- a/Config/DefaultEngine.ini +++ b/Config/DefaultEngine.ini @@ -128,3 +128,15 @@ CompressionQualityModifier=1.000000 AutoStreamingThreshold=0.000000 SoundCueCookQualityIndex=-1 +[/Script/GameplayDebugger.GameplayDebuggerConfig] +CategorySlot1=One +CategorySlot2=Two +CategorySlot3=Three +CategorySlot4=Four +CategorySlot5=Five +CategorySlot6=Six +CategorySlot7=Seven +CategorySlot8=Eight +CategorySlot9=Nine +CategorySlot0=Zero + diff --git a/Content/Levels/Top_layer_level.umap b/Content/Levels/Top_layer_level.umap index b2c1483..a836a5f 100644 --- a/Content/Levels/Top_layer_level.umap +++ b/Content/Levels/Top_layer_level.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:255a45f7e3d4362cc3378dd7a9858608bc92e2b4aa43fbe22db8e72eaa11e126 +oid sha256:483069f41683db60a67e1b2417c5f3cd17005922d2a67500997ebbc20cb3cbba size 247199 diff --git a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp index 661de57..6a7ace7 100644 --- a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp +++ b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp @@ -5,10 +5,11 @@ #include "Blueprint/UserWidget.h" #include "the_twilight_abyss/BaseItems/InventoryComponent.h" #include "the_twilight_abyss/BaseItems/Items/BaseItem.h" -#include "Components/CapsuleComponent.h" #include "GameFramework/CharacterMovementComponent.h" #include "the_twilight_abyss/MerchantInteraction/Interaction.h" #include +#include "Components/SphereComponent.h" +#include "Kismet/KismetMathLibrary.h" // CONSTRUCTOR @@ -37,6 +38,7 @@ void ATempCharacter::BeginPlay() UGameplayStatics::GetAllActorsOfClass(GetWorld(), APostProcessVolume::StaticClass(), AllActorsInScene); PostProcessVolume = Cast(AllActorsInScene[0]); + Enemy = TEXT("Enemy"); UGameplayStatics::GetAllActorsWithTag(GetWorld(), Enemy, AIActors); } @@ -58,10 +60,26 @@ void ATempCharacter::Sneak() { UnCrouch(); PostProcessVolume->Settings.VignetteIntensity = 0.0f; + for (AActor* Actor : AIActors) + { + USphereComponent* SphereComponent = Actor->FindComponentByClass(); + if (SphereComponent != nullptr) + { + SphereComponent->SetSphereRadius(40.0f); //default value + } + } } else { Crouch(); + for (AActor* Actor : AIActors) + { + USphereComponent* SphereComponent = Actor->FindComponentByClass(); + if (SphereComponent != nullptr) + { + SphereComponent->SetSphereRadius(15.0f); + } + } PostProcessVolume->Settings.VignetteIntensity = 0.8f; } @@ -185,11 +203,7 @@ void ATempCharacter::InputDisabler() PlayerController->bShowMouseCursor = true; disableTab = true; - if (ThisCamera == nullptr) - { - return; - } - else + if (ThisCamera != nullptr) { OriginalCameraLocation = ThisCamera->GetComponentLocation(); OriginalCameraRotation = ThisCamera->GetComponentRotation(); @@ -213,11 +227,7 @@ void ATempCharacter::InputEnabler() UE_LOG(LogTemp, Display, TEXT("Enabling Inputs")); disableTab = true; TraceDistance = 300; - if (ThisCamera == nullptr) - { - return; - } - else + if (ThisCamera != nullptr) { ThisCamera->SetWorldLocation(OriginalCameraLocation); ThisCamera->SetWorldRotation(OriginalCameraRotation); diff --git a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h index 4c6c866..44ba91e 100644 --- a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h +++ b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h @@ -6,7 +6,6 @@ #include "GameFramework/Character.h" #include "the_twilight_abyss/BaseItems/Items/BaseItem.h" #include "Camera/CameraComponent.h" -#include "Kismet/KismetMathLibrary.h" #include "Engine/PostProcessVolume.h" #include "TempCharacter.generated.h"