Updated TempCharacter to create NoiseEmitter
Got the NoiseEmitter component and then used the makenoise function to make it create noise everytime the player walks
This commit is contained in:
parent
9acc103506
commit
4357537009
BIN
Content/Blueprints/Display_UI/WBP_Health.uasset
(Stored with Git LFS)
BIN
Content/Blueprints/Display_UI/WBP_Health.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Blueprints/Player/BP_MyTempCharacter.uasset
(Stored with Git LFS)
BIN
Content/Blueprints/Player/BP_MyTempCharacter.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Levels/Top_layer_level.umap
(Stored with Git LFS)
BIN
Content/Levels/Top_layer_level.umap
(Stored with Git LFS)
Binary file not shown.
@ -8,6 +8,8 @@
|
|||||||
#include "GameFramework/CharacterMovementComponent.h"
|
#include "GameFramework/CharacterMovementComponent.h"
|
||||||
#include "the_twilight_abyss/MerchantInteraction/Interaction.h"
|
#include "the_twilight_abyss/MerchantInteraction/Interaction.h"
|
||||||
#include <Runtime/Engine/Classes/Kismet/GameplayStatics.h>
|
#include <Runtime/Engine/Classes/Kismet/GameplayStatics.h>
|
||||||
|
|
||||||
|
#include "Components/PawnNoiseEmitterComponent.h"
|
||||||
#include "Components/SphereComponent.h"
|
#include "Components/SphereComponent.h"
|
||||||
#include "Kismet/KismetMathLibrary.h"
|
#include "Kismet/KismetMathLibrary.h"
|
||||||
|
|
||||||
@ -19,8 +21,6 @@ ATempCharacter::ATempCharacter()
|
|||||||
PrimaryActorTick.bCanEverTick = true;
|
PrimaryActorTick.bCanEverTick = true;
|
||||||
Inventory = CreateDefaultSubobject<UInventoryComponent>("Inventory");
|
Inventory = CreateDefaultSubobject<UInventoryComponent>("Inventory");
|
||||||
Inventory->MaxItemSlots = 10;
|
Inventory->MaxItemSlots = 10;
|
||||||
GoldBalance = GoldBalance;
|
|
||||||
Health = Health;
|
|
||||||
this->GetCharacterMovement()->GetNavAgentPropertiesRef().bCanCrouch = true;
|
this->GetCharacterMovement()->GetNavAgentPropertiesRef().bCanCrouch = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,30 +32,34 @@ void ATempCharacter::BeginPlay()
|
|||||||
ThisCamera = Cast<UCameraComponent>(this->FindComponentByClass<UCameraComponent>());
|
ThisCamera = Cast<UCameraComponent>(this->FindComponentByClass<UCameraComponent>());
|
||||||
PlayerCapsule = GetCapsuleComponent();
|
PlayerCapsule = GetCapsuleComponent();
|
||||||
TArray<AActor*> AllActorsInScene;
|
TArray<AActor*> AllActorsInScene;
|
||||||
|
|
||||||
//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);
|
||||||
if (ensureMsgf(AllActorsInScene.Num() > 0, TEXT("No Post Processing Volume in scene")))
|
if (ensureMsgf(AllActorsInScene.Num() > 0, TEXT("No Post Processing Volume in scene")))
|
||||||
{
|
{
|
||||||
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()));
|
||||||
|
if (NoiseEmitter)
|
||||||
|
{
|
||||||
|
UE_LOG(LogTemp, Display, TEXT("Noise Emitter found"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Binds the input we made in the setup player component to the forward vector
|
//Binds the input we made in the setup player component to the forward vector
|
||||||
void ATempCharacter::ForwardInput(float Axis)
|
void ATempCharacter::ForwardInput(float Axis)
|
||||||
{
|
{
|
||||||
AddMovementInput(UKismetMathLibrary::GetForwardVector(FRotator(0, GetControlRotation().Yaw, 0)) * Axis);
|
AddMovementInput(UKismetMathLibrary::GetForwardVector(FRotator(0, GetControlRotation().Yaw, 0)) * Axis);
|
||||||
|
if (isInStealth == false) MakeNoise(1.0f, this, GetActorLocation(), 1200.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Binds the input we made in the setup player component to the right vector
|
//Binds the input we made in the setup player component to the right vector
|
||||||
void ATempCharacter::RightMoveInput(float Axis)
|
void ATempCharacter::RightMoveInput(float Axis)
|
||||||
{
|
{
|
||||||
AddMovementInput(UKismetMathLibrary::GetRightVector(FRotator(0, GetControlRotation().Yaw, 0)) * Axis);
|
AddMovementInput(UKismetMathLibrary::GetRightVector(FRotator(0, GetControlRotation().Yaw, 0)) * Axis);
|
||||||
|
if (isInStealth == false) MakeNoise(1.0f, this, GetActorLocation(), 1200.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ATempCharacter::Sneak()
|
void ATempCharacter::Sneak()
|
||||||
@ -64,6 +68,7 @@ void ATempCharacter::Sneak()
|
|||||||
if (bIsCrouched)
|
if (bIsCrouched)
|
||||||
{
|
{
|
||||||
UnCrouch();
|
UnCrouch();
|
||||||
|
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)
|
||||||
{
|
{
|
||||||
@ -77,12 +82,13 @@ void ATempCharacter::Sneak()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
Crouch();
|
Crouch();
|
||||||
|
isInStealth = true;
|
||||||
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(5.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (PostProcessVolume != nullptr) PostProcessVolume->Settings.VignetteIntensity = 0.8f;
|
if (PostProcessVolume != nullptr) PostProcessVolume->Settings.VignetteIntensity = 0.8f;
|
||||||
|
@ -52,7 +52,8 @@ public:
|
|||||||
void InputDisabler();
|
void InputDisabler();
|
||||||
void LineTraceLogic();
|
void LineTraceLogic();
|
||||||
|
|
||||||
|
UPROPERTY()
|
||||||
|
class UPawnNoiseEmitterComponent* NoiseEmitter;
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category= "Health")
|
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category= "Health")
|
||||||
float Health;
|
float Health;
|
||||||
@ -97,4 +98,6 @@ public:
|
|||||||
|
|
||||||
UPROPERTY(BlueprintReadWrite)
|
UPROPERTY(BlueprintReadWrite)
|
||||||
float ReactionSpeed = 100.0f;
|
float ReactionSpeed = 100.0f;
|
||||||
|
|
||||||
|
bool isInStealth = false;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user