Updated TempCharacter to sneak functionality

Added sneak functionality which makes the sphere radius smaller near enemies.
This commit is contained in:
MH261677 2023-02-17 13:12:28 +00:00
parent 77c43ab3d1
commit 43ef8e2110
4 changed files with 34 additions and 13 deletions

View File

@ -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

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:255a45f7e3d4362cc3378dd7a9858608bc92e2b4aa43fbe22db8e72eaa11e126
oid sha256:483069f41683db60a67e1b2417c5f3cd17005922d2a67500997ebbc20cb3cbba
size 247199

View File

@ -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 <Runtime/Engine/Classes/Kismet/GameplayStatics.h>
#include "Components/SphereComponent.h"
#include "Kismet/KismetMathLibrary.h"
// CONSTRUCTOR
@ -37,6 +38,7 @@ void ATempCharacter::BeginPlay()
UGameplayStatics::GetAllActorsOfClass(GetWorld(), APostProcessVolume::StaticClass(), AllActorsInScene);
PostProcessVolume = Cast<APostProcessVolume>(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<USphereComponent>();
if (SphereComponent != nullptr)
{
SphereComponent->SetSphereRadius(40.0f); //default value
}
}
}
else
{
Crouch();
for (AActor* Actor : AIActors)
{
USphereComponent* SphereComponent = Actor->FindComponentByClass<USphereComponent>();
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);

View File

@ -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"