Merge branch 'AI-n-Stuff' into dev
This commit is contained in:
commit
bb832fedd2
BIN
EndlessVendetta/Content/AI/Enemy/Basic/BT_BasicEnemy.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/AI/Enemy/Basic/BT_BasicEnemy.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
EndlessVendetta/Content/AdvancedLocomotionV4/Blueprints/AnimNotifys/Footstep_AnimNotify.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/AdvancedLocomotionV4/Blueprints/AnimNotifys/Footstep_AnimNotify.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
EndlessVendetta/Content/FirstPerson/Blueprints/BP_MainCharacter.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/FirstPerson/Blueprints/BP_MainCharacter.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
EndlessVendetta/Content/__ExternalActors__/Levels/MovementTest/C/ZX/8GZK30F02QUUO234VY329I.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/__ExternalActors__/Levels/MovementTest/C/ZX/8GZK30F02QUUO234VY329I.uasset
(Stored with Git LFS)
Binary file not shown.
@ -4,7 +4,6 @@
|
|||||||
#include "AICharacter.h"
|
#include "AICharacter.h"
|
||||||
|
|
||||||
#include "Components/CapsuleComponent.h"
|
#include "Components/CapsuleComponent.h"
|
||||||
#include "Engine/DamageEvents.h"
|
|
||||||
#include "GameFramework/CharacterMovementComponent.h"
|
#include "GameFramework/CharacterMovementComponent.h"
|
||||||
#include "Perception/AIPerceptionStimuliSourceComponent.h"
|
#include "Perception/AIPerceptionStimuliSourceComponent.h"
|
||||||
#include "Perception/AISense_Sight.h"
|
#include "Perception/AISense_Sight.h"
|
||||||
|
@ -55,7 +55,9 @@ void AAI_EnemyController::Tick(float DeltaTime)
|
|||||||
Super::Tick(DeltaTime);
|
Super::Tick(DeltaTime);
|
||||||
if (GetBlackboardComponent()->GetValueAsBool("CanSeePlayer"))
|
if (GetBlackboardComponent()->GetValueAsBool("CanSeePlayer"))
|
||||||
{
|
{
|
||||||
GetBlackboardComponent()->SetValueAsVector("TargetLocation", GetWorld()->GetFirstPlayerController()->GetPawn()->GetActorLocation());
|
GetBlackboardComponent()->SetValueAsVector("TargetLocation",
|
||||||
|
GetWorld()->GetFirstPlayerController()->GetPawn()->
|
||||||
|
GetActorLocation());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,14 +73,15 @@ void AAI_EnemyController::SetupPerceptionSystem()
|
|||||||
SightConfig->SightRadius = 2000.0f;
|
SightConfig->SightRadius = 2000.0f;
|
||||||
SightConfig->LoseSightRadius = 2100.0f;
|
SightConfig->LoseSightRadius = 2100.0f;
|
||||||
SightConfig->PeripheralVisionAngleDegrees = 70.0f;
|
SightConfig->PeripheralVisionAngleDegrees = 70.0f;
|
||||||
SightConfig->SetMaxAge(20.0f);
|
SightConfig->SetMaxAge(5.0f);
|
||||||
SightConfig->AutoSuccessRangeFromLastSeenLocation = 520.0f;
|
SightConfig->AutoSuccessRangeFromLastSeenLocation = 100.0f;
|
||||||
SightConfig->DetectionByAffiliation.bDetectEnemies = true;
|
SightConfig->DetectionByAffiliation.bDetectEnemies = true;
|
||||||
SightConfig->DetectionByAffiliation.bDetectFriendlies = true;
|
SightConfig->DetectionByAffiliation.bDetectFriendlies = true;
|
||||||
SightConfig->DetectionByAffiliation.bDetectNeutrals = true;
|
SightConfig->DetectionByAffiliation.bDetectNeutrals = true;
|
||||||
|
|
||||||
HearingConfig = CreateDefaultSubobject<UAISenseConfig_Hearing>(TEXT("Hearing Config"));
|
HearingConfig = CreateDefaultSubobject<UAISenseConfig_Hearing>(TEXT("Hearing Config"));
|
||||||
HearingConfig->HearingRange = 2000.0f;
|
HearingConfig->HearingRange = 2000.0f;
|
||||||
|
HearingConfig->SetMaxAge(20.0f);
|
||||||
HearingConfig->DetectionByAffiliation.bDetectEnemies = true;
|
HearingConfig->DetectionByAffiliation.bDetectEnemies = true;
|
||||||
HearingConfig->DetectionByAffiliation.bDetectFriendlies = true;
|
HearingConfig->DetectionByAffiliation.bDetectFriendlies = true;
|
||||||
HearingConfig->DetectionByAffiliation.bDetectNeutrals = true;
|
HearingConfig->DetectionByAffiliation.bDetectNeutrals = true;
|
||||||
@ -88,7 +91,8 @@ void AAI_EnemyController::SetupPerceptionSystem()
|
|||||||
|
|
||||||
SetPerceptionComponent(*CreateDefaultSubobject<UAIPerceptionComponent>(TEXT("Perception Component")));
|
SetPerceptionComponent(*CreateDefaultSubobject<UAIPerceptionComponent>(TEXT("Perception Component")));
|
||||||
GetPerceptionComponent()->SetDominantSense(*SightConfig->GetSenseImplementation());
|
GetPerceptionComponent()->SetDominantSense(*SightConfig->GetSenseImplementation());
|
||||||
GetPerceptionComponent()->OnTargetPerceptionUpdated.AddDynamic(this, &AAI_EnemyController::OnTargetPerceptionUpdated);
|
GetPerceptionComponent()->OnTargetPerceptionUpdated.AddDynamic(
|
||||||
|
this, &AAI_EnemyController::OnTargetPerceptionUpdated);
|
||||||
GetPerceptionComponent()->ConfigureSense(*SightConfig);
|
GetPerceptionComponent()->ConfigureSense(*SightConfig);
|
||||||
GetPerceptionComponent()->ConfigureSense(*HearingConfig);
|
GetPerceptionComponent()->ConfigureSense(*HearingConfig);
|
||||||
}
|
}
|
||||||
@ -102,6 +106,10 @@ void AAI_EnemyController::OnTargetPerceptionUpdated(AActor* Actor, FAIStimulus c
|
|||||||
GetBlackboardComponent()->SetValueAsObject("TargetPlayer", Actor);
|
GetBlackboardComponent()->SetValueAsObject("TargetPlayer", Actor);
|
||||||
GetBlackboardComponent()->SetValueAsVector("TargetLocation", Stimulus.StimulusLocation);
|
GetBlackboardComponent()->SetValueAsVector("TargetLocation", Stimulus.StimulusLocation);
|
||||||
GetBlackboardComponent()->SetValueAsBool("CanSeePlayer", true);
|
GetBlackboardComponent()->SetValueAsBool("CanSeePlayer", true);
|
||||||
|
if (PlayerCharacter->CurrentOverlayState != EOverlayState::Default)
|
||||||
|
{
|
||||||
|
GetBlackboardComponent()->SetValueAsBool("IsHostile", true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (!Stimulus.WasSuccessfullySensed() && Stimulus.Type == SightConfig->GetSenseID())
|
else if (!Stimulus.WasSuccessfullySensed() && Stimulus.Type == SightConfig->GetSenseID())
|
||||||
{
|
{
|
||||||
@ -116,5 +124,11 @@ void AAI_EnemyController::OnTargetPerceptionUpdated(AActor* Actor, FAIStimulus c
|
|||||||
GetBlackboardComponent()->SetValueAsVector("InvestigationLocation", Stimulus.StimulusLocation);
|
GetBlackboardComponent()->SetValueAsVector("InvestigationLocation", Stimulus.StimulusLocation);
|
||||||
GetBlackboardComponent()->SetValueAsBool("IsInvestigating", true);
|
GetBlackboardComponent()->SetValueAsBool("IsInvestigating", true);
|
||||||
}
|
}
|
||||||
|
else if (!Stimulus.WasSuccessfullySensed() && Stimulus.Type == HearingConfig->GetSenseID())
|
||||||
|
{
|
||||||
|
GetBlackboardComponent()->ClearValue("TargetPlayer");
|
||||||
|
GetBlackboardComponent()->ClearValue("InvestigationLocation");
|
||||||
|
GetBlackboardComponent()->SetValueAsBool("IsInvestigating", false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ AEndlessVendettaCharacter::AEndlessVendettaCharacter()
|
|||||||
GetCharacterMovement()->GetNavAgentPropertiesRef().bCanCrouch = true;
|
GetCharacterMovement()->GetNavAgentPropertiesRef().bCanCrouch = true;
|
||||||
// Set size for collision capsule
|
// Set size for collision capsule
|
||||||
GetCapsuleComponent()->InitCapsuleSize(55.f, 96.0f);
|
GetCapsuleComponent()->InitCapsuleSize(55.f, 96.0f);
|
||||||
|
CreateDefaultSubobject<UPawnNoiseEmitterComponent>(TEXT("PawnNoiseEmitter"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AEndlessVendettaCharacter::IncrementRestrictedBoundsCount()
|
void AEndlessVendettaCharacter::IncrementRestrictedBoundsCount()
|
||||||
@ -65,8 +66,9 @@ void AEndlessVendettaCharacter::ReloadAnimationComplete()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AEndlessVendettaCharacter::SetOverlayState(const EOverlayState OverlayState) const
|
void AEndlessVendettaCharacter::SetOverlayState(const EOverlayState OverlayState)
|
||||||
{
|
{
|
||||||
|
CurrentOverlayState = OverlayState;
|
||||||
SetOverlayStateEvent.Broadcast(OverlayState);
|
SetOverlayStateEvent.Broadcast(OverlayState);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,8 +81,14 @@ void AEndlessVendettaCharacter::BeginPlay()
|
|||||||
{
|
{
|
||||||
// Call the base class
|
// Call the base class
|
||||||
Super::BeginPlay();
|
Super::BeginPlay();
|
||||||
FirstPersonArms = Cast<USkeletalMeshComponent>(GetComponentsByTag(USkeletalMeshComponent::StaticClass(), FName("FirstPersonArms"))[0]);
|
|
||||||
HeldWeapon = Cast<UChildActorComponent>(GetComponentsByTag(UChildActorComponent::StaticClass(), FName("Weapon"))[0]);
|
PawnNoiseEmitterComp = Cast<UPawnNoiseEmitterComponent>(
|
||||||
|
GetComponentByClass(UPawnNoiseEmitterComponent::StaticClass()));
|
||||||
|
|
||||||
|
FirstPersonArms = Cast<USkeletalMeshComponent>(
|
||||||
|
GetComponentsByTag(USkeletalMeshComponent::StaticClass(), FName("FirstPersonArms"))[0]);
|
||||||
|
HeldWeapon = Cast<
|
||||||
|
UChildActorComponent>(GetComponentsByTag(UChildActorComponent::StaticClass(), FName("Weapon"))[0]);
|
||||||
|
|
||||||
bIsCurrentlyHoldingWeapon = false;
|
bIsCurrentlyHoldingWeapon = false;
|
||||||
UEVGameInstance* GI = Cast<UEVGameInstance>(GetWorld()->GetGameInstance());
|
UEVGameInstance* GI = Cast<UEVGameInstance>(GetWorld()->GetGameInstance());
|
||||||
@ -93,12 +101,14 @@ void AEndlessVendettaCharacter::BeginPlay()
|
|||||||
//Add Input Mapping Context
|
//Add Input Mapping Context
|
||||||
if (APlayerController* PlayerController = Cast<APlayerController>(Controller))
|
if (APlayerController* PlayerController = Cast<APlayerController>(Controller))
|
||||||
{
|
{
|
||||||
if (UEnhancedInputLocalPlayerSubsystem* Subsystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(PlayerController->GetLocalPlayer()))
|
if (UEnhancedInputLocalPlayerSubsystem* Subsystem = ULocalPlayer::GetSubsystem<
|
||||||
|
UEnhancedInputLocalPlayerSubsystem>(PlayerController->GetLocalPlayer()))
|
||||||
{
|
{
|
||||||
Subsystem->AddMappingContext(DefaultMappingContext, 0);
|
Subsystem->AddMappingContext(DefaultMappingContext, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AActor* GadgetManagerActor = GetWorld()->SpawnActor<AActor>(GadgetManagerClass, GetActorLocation(), GetActorRotation());
|
AActor* GadgetManagerActor = GetWorld()->SpawnActor<AActor>(GadgetManagerClass, GetActorLocation(),
|
||||||
|
GetActorRotation());
|
||||||
GadgetManager = Cast<AGadgetManager>(GadgetManagerActor);
|
GadgetManager = Cast<AGadgetManager>(GadgetManagerActor);
|
||||||
FAttachmentTransformRules AttachmentRules(EAttachmentRule::SnapToTarget, true);
|
FAttachmentTransformRules AttachmentRules(EAttachmentRule::SnapToTarget, true);
|
||||||
GadgetManagerActor->AttachToComponent(GetRootComponent(), AttachmentRules);
|
GadgetManagerActor->AttachToComponent(GetRootComponent(), AttachmentRules);
|
||||||
@ -168,7 +178,8 @@ void AEndlessVendettaCharacter::RegenHealth()
|
|||||||
if (GetWorld()->GetTimerManager().GetTimerRate(RegenHealthTimerHandle) > 1.0f)
|
if (GetWorld()->GetTimerManager().GetTimerRate(RegenHealthTimerHandle) > 1.0f)
|
||||||
{
|
{
|
||||||
GetWorld()->GetTimerManager().ClearTimer(RegenHealthTimerHandle);
|
GetWorld()->GetTimerManager().ClearTimer(RegenHealthTimerHandle);
|
||||||
GetWorld()->GetTimerManager().SetTimer(RegenHealthTimerHandle, this, &AEndlessVendettaCharacter::RegenHealth, 1.0f, true);
|
GetWorld()->GetTimerManager().SetTimer(RegenHealthTimerHandle, this, &AEndlessVendettaCharacter::RegenHealth,
|
||||||
|
1.0f, true);
|
||||||
}
|
}
|
||||||
if (CurrentHealth >= MaxHealth) GetWorld()->GetTimerManager().ClearTimer(RegenHealthTimerHandle);
|
if (CurrentHealth >= MaxHealth) GetWorld()->GetTimerManager().ClearTimer(RegenHealthTimerHandle);
|
||||||
}
|
}
|
||||||
@ -215,37 +226,53 @@ void AEndlessVendettaCharacter::SetupPlayerInputComponent(class UInputComponent*
|
|||||||
|
|
||||||
//Moving
|
//Moving
|
||||||
// EnhancedInputComponent->BindAction(MoveAction, ETriggerEvent::Triggered, this, &AEndlessVendettaCharacter::Move);
|
// EnhancedInputComponent->BindAction(MoveAction, ETriggerEvent::Triggered, this, &AEndlessVendettaCharacter::Move);
|
||||||
EnhancedInputComponent->BindAction(SprintAction, ETriggerEvent::Started, this, &AEndlessVendettaCharacter::Sprint);
|
EnhancedInputComponent->BindAction(SprintAction, ETriggerEvent::Started, this,
|
||||||
EnhancedInputComponent->BindAction(SprintAction, ETriggerEvent::Completed, this, &AEndlessVendettaCharacter::StopSprint);
|
&AEndlessVendettaCharacter::Sprint);
|
||||||
|
EnhancedInputComponent->BindAction(SprintAction, ETriggerEvent::Completed, this,
|
||||||
|
&AEndlessVendettaCharacter::StopSprint);
|
||||||
|
|
||||||
//Looking
|
//Looking
|
||||||
// EnhancedInputComponent->BindAction(LookAction, ETriggerEvent::Triggered, this, &AEndlessVendettaCharacter::Look);
|
// EnhancedInputComponent->BindAction(LookAction, ETriggerEvent::Triggered, this, &AEndlessVendettaCharacter::Look);
|
||||||
|
|
||||||
// Gadget Toggling
|
// Gadget Toggling
|
||||||
EnhancedInputComponent->BindAction(ReconAction, ETriggerEvent::Started, this, &AEndlessVendettaCharacter::ToggleRecon);
|
EnhancedInputComponent->BindAction(ReconAction, ETriggerEvent::Started, this,
|
||||||
EnhancedInputComponent->BindAction(CombatAction, ETriggerEvent::Started, this, &AEndlessVendettaCharacter::ToggleCombat);
|
&AEndlessVendettaCharacter::ToggleRecon);
|
||||||
|
EnhancedInputComponent->BindAction(CombatAction, ETriggerEvent::Started, this,
|
||||||
|
&AEndlessVendettaCharacter::ToggleCombat);
|
||||||
|
|
||||||
//Weapon Switching
|
//Weapon Switching
|
||||||
EnhancedInputComponent->BindAction(EquipPrimaryWeapon, ETriggerEvent::Triggered, this, &AEndlessVendettaCharacter::EquipPrimary);
|
EnhancedInputComponent->BindAction(EquipPrimaryWeapon, ETriggerEvent::Triggered, this,
|
||||||
EnhancedInputComponent->BindAction(EquipSecondaryWeapon, ETriggerEvent::Triggered, this, &AEndlessVendettaCharacter::EquipSecondary);
|
&AEndlessVendettaCharacter::EquipPrimary);
|
||||||
|
EnhancedInputComponent->BindAction(EquipSecondaryWeapon, ETriggerEvent::Triggered, this,
|
||||||
|
&AEndlessVendettaCharacter::EquipSecondary);
|
||||||
|
|
||||||
//Weapon Shooting
|
//Weapon Shooting
|
||||||
EnhancedInputComponent->BindAction(TapShootAction, ETriggerEvent::Triggered, this, &AEndlessVendettaCharacter::FireCaller);
|
EnhancedInputComponent->BindAction(TapShootAction, ETriggerEvent::Triggered, this,
|
||||||
EnhancedInputComponent->BindAction(TapShootAction, ETriggerEvent::Completed, this, &AEndlessVendettaCharacter::StopFire);
|
&AEndlessVendettaCharacter::FireCaller);
|
||||||
EnhancedInputComponent->BindAction(GunAimInAction, ETriggerEvent::Triggered, this, &AEndlessVendettaCharacter::GunRightClick);
|
EnhancedInputComponent->BindAction(TapShootAction, ETriggerEvent::Completed, this,
|
||||||
EnhancedInputComponent->BindAction(GunAimInAction, ETriggerEvent::Completed, this, &AEndlessVendettaCharacter::StopGunRightClick);
|
&AEndlessVendettaCharacter::StopFire);
|
||||||
|
EnhancedInputComponent->BindAction(GunAimInAction, ETriggerEvent::Triggered, this,
|
||||||
|
&AEndlessVendettaCharacter::GunRightClick);
|
||||||
|
EnhancedInputComponent->BindAction(GunAimInAction, ETriggerEvent::Completed, this,
|
||||||
|
&AEndlessVendettaCharacter::StopGunRightClick);
|
||||||
|
|
||||||
//Weapon Reloading
|
//Weapon Reloading
|
||||||
EnhancedInputComponent->BindAction(GunReloadAction, ETriggerEvent::Started, this, &AEndlessVendettaCharacter::GunReload);
|
EnhancedInputComponent->BindAction(GunReloadAction, ETriggerEvent::Started, this,
|
||||||
|
&AEndlessVendettaCharacter::GunReload);
|
||||||
|
|
||||||
//Crouching
|
//Crouching
|
||||||
EnhancedInputComponent->BindAction(CrouchAction, ETriggerEvent::Started, this, &AEndlessVendettaCharacter::SetCrouch);
|
EnhancedInputComponent->BindAction(CrouchAction, ETriggerEvent::Started, this,
|
||||||
EnhancedInputComponent->BindAction(CrouchAction, ETriggerEvent::Completed, this, &AEndlessVendettaCharacter::SetUnCrouch);
|
&AEndlessVendettaCharacter::SetCrouch);
|
||||||
|
EnhancedInputComponent->BindAction(CrouchAction, ETriggerEvent::Completed, this,
|
||||||
|
&AEndlessVendettaCharacter::SetUnCrouch);
|
||||||
|
|
||||||
//Interacting
|
//Interacting
|
||||||
EnhancedInputComponent->BindAction(InteractAction, ETriggerEvent::Started, this, &AEndlessVendettaCharacter::Interact);
|
EnhancedInputComponent->BindAction(InteractAction, ETriggerEvent::Started, this,
|
||||||
EnhancedInputComponent->BindAction(InteractAction, ETriggerEvent::Triggered, this, &AEndlessVendettaCharacter::HoldInteract);
|
&AEndlessVendettaCharacter::Interact);
|
||||||
EnhancedInputComponent->BindAction(InteractAction, ETriggerEvent::Canceled, this, &AEndlessVendettaCharacter::StoppedHoldingInteract);
|
EnhancedInputComponent->BindAction(InteractAction, ETriggerEvent::Triggered, this,
|
||||||
|
&AEndlessVendettaCharacter::HoldInteract);
|
||||||
|
EnhancedInputComponent->BindAction(InteractAction, ETriggerEvent::Canceled, this,
|
||||||
|
&AEndlessVendettaCharacter::StoppedHoldingInteract);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,7 +283,8 @@ void AEndlessVendettaCharacter::Interact()
|
|||||||
if (InPauseMenu) return;
|
if (InPauseMenu) return;
|
||||||
if (bIsInDialogue)
|
if (bIsInDialogue)
|
||||||
{
|
{
|
||||||
Cast<UAC_PlayerDialogueInterpreter>(GetComponentByClass(UAC_PlayerDialogueInterpreter::StaticClass()))->NextDialogue();
|
Cast<UAC_PlayerDialogueInterpreter>(GetComponentByClass(UAC_PlayerDialogueInterpreter::StaticClass()))->
|
||||||
|
NextDialogue();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
StartedHoldingInteract(1.f / HoldForInteractionDuration);
|
StartedHoldingInteract(1.f / HoldForInteractionDuration);
|
||||||
@ -301,7 +329,8 @@ void AEndlessVendettaCharacter::SetUnCrouch()
|
|||||||
UnCrouch();
|
UnCrouch();
|
||||||
}
|
}
|
||||||
|
|
||||||
float AEndlessVendettaCharacter::TakeDamage(const float DamageAmount, FDamageEvent const& DamageEvent, AController* EventInstigator, AActor* DamageCauser)
|
float AEndlessVendettaCharacter::TakeDamage(const float DamageAmount, FDamageEvent const& DamageEvent,
|
||||||
|
AController* EventInstigator, AActor* DamageCauser)
|
||||||
{
|
{
|
||||||
CurrentHealth -= DamageAmount;
|
CurrentHealth -= DamageAmount;
|
||||||
if (CurrentHealth <= 0)
|
if (CurrentHealth <= 0)
|
||||||
@ -330,7 +359,8 @@ float AEndlessVendettaCharacter::TakeDamage(const float DamageAmount, FDamageEve
|
|||||||
TookDamage.Broadcast();
|
TookDamage.Broadcast();
|
||||||
|
|
||||||
GetWorld()->GetTimerManager().ClearTimer(RegenHealthTimerHandle);
|
GetWorld()->GetTimerManager().ClearTimer(RegenHealthTimerHandle);
|
||||||
GetWorld()->GetTimerManager().SetTimer(RegenHealthTimerHandle, this, &AEndlessVendettaCharacter::RegenHealth, 5.0f, true);
|
GetWorld()->GetTimerManager().SetTimer(RegenHealthTimerHandle, this, &AEndlessVendettaCharacter::RegenHealth, 5.0f,
|
||||||
|
true);
|
||||||
|
|
||||||
return Super::TakeDamage(DamageAmount, DamageEvent, EventInstigator, DamageCauser);
|
return Super::TakeDamage(DamageAmount, DamageEvent, EventInstigator, DamageCauser);
|
||||||
}
|
}
|
||||||
@ -351,7 +381,8 @@ void AEndlessVendettaCharacter::ToggleRecon()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GadgetManager->IsValidCombatGadget() && GadgetManager->IsCombatEquipped() && !GadgetManager->TryToUnequipCombat())
|
if (GadgetManager->IsValidCombatGadget() && GadgetManager->IsCombatEquipped() && !GadgetManager->
|
||||||
|
TryToUnequipCombat())
|
||||||
{
|
{
|
||||||
// Do nothing if combat is equipped and can't be unequipped at this moment
|
// Do nothing if combat is equipped and can't be unequipped at this moment
|
||||||
return;
|
return;
|
||||||
@ -418,8 +449,11 @@ void AEndlessVendettaCharacter::EquipPrimary()
|
|||||||
|
|
||||||
if (IsValid(SecondaryWeapon)) EquipSecondary();
|
if (IsValid(SecondaryWeapon)) EquipSecondary();
|
||||||
|
|
||||||
if (GadgetManager->IsValidReconGadget() && GadgetManager->IsReconEquipped() && !GadgetManager->TryToUnequipRecon()) return;
|
if (GadgetManager->IsValidReconGadget() && GadgetManager->IsReconEquipped() && !GadgetManager->TryToUnequipRecon())
|
||||||
if (GadgetManager->IsValidCombatGadget() && GadgetManager->IsCombatEquipped() && !GadgetManager->TryToUnequipCombat()) return;
|
return;
|
||||||
|
if (GadgetManager->IsValidCombatGadget() && GadgetManager->IsCombatEquipped() && !GadgetManager->
|
||||||
|
TryToUnequipCombat())
|
||||||
|
return;
|
||||||
|
|
||||||
//this code handles when you FIRST dont have any primary weapon
|
//this code handles when you FIRST dont have any primary weapon
|
||||||
if (!IsValid(PrimaryWeapon))
|
if (!IsValid(PrimaryWeapon))
|
||||||
@ -482,8 +516,11 @@ void AEndlessVendettaCharacter::EquipSecondary()
|
|||||||
|
|
||||||
if (IsValid(PrimaryWeapon)) EquipPrimary();
|
if (IsValid(PrimaryWeapon)) EquipPrimary();
|
||||||
|
|
||||||
if (GadgetManager->IsValidReconGadget() && GadgetManager->IsReconEquipped() && !GadgetManager->TryToUnequipRecon()) return;
|
if (GadgetManager->IsValidReconGadget() && GadgetManager->IsReconEquipped() && !GadgetManager->TryToUnequipRecon())
|
||||||
if (GadgetManager->IsValidCombatGadget() && GadgetManager->IsCombatEquipped() && !GadgetManager->TryToUnequipCombat()) return;
|
return;
|
||||||
|
if (GadgetManager->IsValidCombatGadget() && GadgetManager->IsCombatEquipped() && !GadgetManager->
|
||||||
|
TryToUnequipCombat())
|
||||||
|
return;
|
||||||
|
|
||||||
if (!IsValid(SecondaryWeapon))
|
if (!IsValid(SecondaryWeapon))
|
||||||
{
|
{
|
||||||
@ -562,10 +599,13 @@ void AEndlessVendettaCharacter::WeaponSwitcher(AActor* Outhit)
|
|||||||
{
|
{
|
||||||
if (bIsCurrentlyHoldingWeapon)
|
if (bIsCurrentlyHoldingWeapon)
|
||||||
{
|
{
|
||||||
GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::Blue, TEXT("bIsCurrentlyHoldingSecondaryCalled, trying to spawn secondary weapon actor"));
|
GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::Blue,
|
||||||
|
TEXT(
|
||||||
|
"bIsCurrentlyHoldingSecondaryCalled, trying to spawn secondary weapon actor"));
|
||||||
SecondaryWeaponActor = GetWorld()->SpawnActor<AActor>(SecondaryWeaponClass, spawnParams);
|
SecondaryWeaponActor = GetWorld()->SpawnActor<AActor>(SecondaryWeaponClass, spawnParams);
|
||||||
}
|
}
|
||||||
GEngine->AddOnScreenDebugMessage(-1, 15.f, FColor::Orange, TEXT("EquipSecondarycalled skipped bIsCurrentlyHoldingWeapon check"));
|
GEngine->AddOnScreenDebugMessage(-1, 15.f, FColor::Orange,
|
||||||
|
TEXT("EquipSecondarycalled skipped bIsCurrentlyHoldingWeapon check"));
|
||||||
EquipSecondary();
|
EquipSecondary();
|
||||||
}
|
}
|
||||||
bIsWeaponPickedUp = true;
|
bIsWeaponPickedUp = true;
|
||||||
@ -619,14 +659,16 @@ void AEndlessVendettaCharacter::GunRightClick()
|
|||||||
bIsScoped = true;
|
bIsScoped = true;
|
||||||
PrimaryWeapon->WeaponScopedFire();
|
PrimaryWeapon->WeaponScopedFire();
|
||||||
StartPrimaryWeaponADS();
|
StartPrimaryWeaponADS();
|
||||||
this->GetFirstPersonCameraComponent()->SetFieldOfView(50); //change this number to a number you can change in editor eventually
|
this->GetFirstPersonCameraComponent()->SetFieldOfView(50);
|
||||||
|
//change this number to a number you can change in editor eventually
|
||||||
}
|
}
|
||||||
if (IsValid(SecondaryWeapon) && !bIsScoped)
|
if (IsValid(SecondaryWeapon) && !bIsScoped)
|
||||||
{
|
{
|
||||||
bIsScoped = true;
|
bIsScoped = true;
|
||||||
SecondaryWeapon->WeaponScopedFire();
|
SecondaryWeapon->WeaponScopedFire();
|
||||||
StartSecondaryWeaponADS();
|
StartSecondaryWeaponADS();
|
||||||
this->GetFirstPersonCameraComponent()->SetFieldOfView(50); //change this number to a number you can change in editor eventually
|
this->GetFirstPersonCameraComponent()->SetFieldOfView(50);
|
||||||
|
//change this number to a number you can change in editor eventually
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -771,8 +813,11 @@ bool AEndlessVendettaCharacter::GetHasRifle()
|
|||||||
|
|
||||||
bool AEndlessVendettaCharacter::UpdateGadgetType(TSubclassOf<AGadgetBase> NewGadgetClass)
|
bool AEndlessVendettaCharacter::UpdateGadgetType(TSubclassOf<AGadgetBase> NewGadgetClass)
|
||||||
{
|
{
|
||||||
if (NewGadgetClass.GetDefaultObject()->IsA(AReconGadget::StaticClass()) && GadgetManager->ReconCantBeSwitchedOut()) return false;
|
if (NewGadgetClass.GetDefaultObject()->IsA(AReconGadget::StaticClass()) && GadgetManager->ReconCantBeSwitchedOut())
|
||||||
if (NewGadgetClass.GetDefaultObject()->IsA(ACombatGadget::StaticClass()) && GadgetManager->CombatCantBeSwitchedOut()) return false;
|
return false;
|
||||||
|
if (NewGadgetClass.GetDefaultObject()->IsA(ACombatGadget::StaticClass()) && GadgetManager->
|
||||||
|
CombatCantBeSwitchedOut())
|
||||||
|
return false;
|
||||||
|
|
||||||
for (UActorComponent* PlayersCamera : GetComponentsByTag(UCameraComponent::StaticClass(), FName("PlayersCamera")))
|
for (UActorComponent* PlayersCamera : GetComponentsByTag(UCameraComponent::StaticClass(), FName("PlayersCamera")))
|
||||||
{
|
{
|
||||||
@ -804,8 +849,11 @@ void AEndlessVendettaCharacter::HoldInteract()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GadgetManager->IsValidReconGadget() && GadgetManager->IsReconEquipped() && !GadgetManager->TryToUnequipRecon()) return;
|
if (GadgetManager->IsValidReconGadget() && GadgetManager->IsReconEquipped() && !GadgetManager->TryToUnequipRecon())
|
||||||
if (GadgetManager->IsValidCombatGadget() && GadgetManager->IsCombatEquipped() && !GadgetManager->TryToUnequipCombat()) return;
|
return;
|
||||||
|
if (GadgetManager->IsValidCombatGadget() && GadgetManager->IsCombatEquipped() && !GadgetManager->
|
||||||
|
TryToUnequipCombat())
|
||||||
|
return;
|
||||||
|
|
||||||
FTransform TakeOffTransform = GetActorTransform();
|
FTransform TakeOffTransform = GetActorTransform();
|
||||||
FVector NewLoc = TakeOffTransform.GetLocation();
|
FVector NewLoc = TakeOffTransform.GetLocation();
|
||||||
@ -822,7 +870,8 @@ void AEndlessVendettaCharacter::EnterShip(FTransform TakeoffLoc)
|
|||||||
if (IsValid(SecondaryWeapon)) EquipSecondary();
|
if (IsValid(SecondaryWeapon)) EquipSecondary();
|
||||||
FActorSpawnParameters SpawnParams;
|
FActorSpawnParameters SpawnParams;
|
||||||
SpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
|
SpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
|
||||||
SpaceShip = GetWorld()->SpawnActor<ASpaceShip>(SpaceShipClass, TakeoffLoc.GetLocation(), TakeoffLoc.Rotator(), SpawnParams);
|
SpaceShip = GetWorld()->SpawnActor<ASpaceShip>(SpaceShipClass, TakeoffLoc.GetLocation(), TakeoffLoc.Rotator(),
|
||||||
|
SpawnParams);
|
||||||
PlayerOnShip = true;
|
PlayerOnShip = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ UCLASS(config=Game)
|
|||||||
class AEndlessVendettaCharacter : public ACharacter
|
class AEndlessVendettaCharacter : public ACharacter
|
||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UFUNCTION(BlueprintImplementableEvent)
|
UFUNCTION(BlueprintImplementableEvent)
|
||||||
void TempEquippedPrimary();
|
void TempEquippedPrimary();
|
||||||
@ -105,6 +106,12 @@ private:
|
|||||||
public:
|
public:
|
||||||
AEndlessVendettaCharacter();
|
AEndlessVendettaCharacter();
|
||||||
|
|
||||||
|
UPROPERTY(BlueprintReadOnly)
|
||||||
|
UPawnNoiseEmitterComponent* PawnNoiseEmitterComp;
|
||||||
|
|
||||||
|
UPROPERTY(BlueprintReadOnly)
|
||||||
|
EOverlayState CurrentOverlayState = EOverlayState::Default;
|
||||||
|
|
||||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Stats")
|
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Stats")
|
||||||
float CurrentHealth = 100.0f;
|
float CurrentHealth = 100.0f;
|
||||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Stats")
|
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Stats")
|
||||||
@ -168,7 +175,7 @@ public:
|
|||||||
FSetOverlayState SetOverlayStateEvent;
|
FSetOverlayState SetOverlayStateEvent;
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category = "Weapon")
|
UFUNCTION(BlueprintCallable, Category = "Weapon")
|
||||||
void SetOverlayState(EOverlayState OverlayState) const;
|
void SetOverlayState(EOverlayState OverlayState);
|
||||||
|
|
||||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FRestrictedAreaStatusChangedSignature, bool, bIsInRestrictedAreaLmao);
|
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FRestrictedAreaStatusChangedSignature, bool, bIsInRestrictedAreaLmao);
|
||||||
|
|
||||||
@ -310,7 +317,8 @@ public:
|
|||||||
UCameraComponent* GetFirstPersonCameraComponent() const { return FirstPersonCameraComponent; }
|
UCameraComponent* GetFirstPersonCameraComponent() const { return FirstPersonCameraComponent; }
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category = "Damage Control")
|
UFUNCTION(BlueprintCallable, Category = "Damage Control")
|
||||||
virtual float TakeDamage(float DamageAmount, FDamageEvent const& DamageEvent, AController* EventInstigator, AActor* DamageCauser) override;
|
virtual float TakeDamage(float DamageAmount, FDamageEvent const& DamageEvent, AController* EventInstigator,
|
||||||
|
AActor* DamageCauser) override;
|
||||||
|
|
||||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FTookDamage);
|
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FTookDamage);
|
||||||
|
|
||||||
|
@ -49,7 +49,8 @@ void ABaseWeaponClass::BeginPlay()
|
|||||||
|
|
||||||
if (!IsValid(endlessVendettaChar)) return;
|
if (!IsValid(endlessVendettaChar)) return;
|
||||||
|
|
||||||
for (UActorComponent* actorComp : playerInWorld->GetComponentsByTag(UArrowComponent::StaticClass(), FName("GunStart")))
|
for (UActorComponent* actorComp : playerInWorld->GetComponentsByTag(UArrowComponent::StaticClass(),
|
||||||
|
FName("GunStart")))
|
||||||
{
|
{
|
||||||
GunStartArrow = Cast<UArrowComponent>(actorComp);
|
GunStartArrow = Cast<UArrowComponent>(actorComp);
|
||||||
break;
|
break;
|
||||||
@ -83,7 +84,8 @@ void ABaseWeaponClass::Tick(float DeltaTime)
|
|||||||
// Recoil Handling ////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
// Recoil Handling ////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
void ABaseWeaponClass::GenerateRecoilVector()
|
void ABaseWeaponClass::GenerateRecoilVector()
|
||||||
{
|
{
|
||||||
float angle = FMath::RandRange(recoilMaxAngleLeft, -recoilMaxAngleRight); //randomg recoil vector angle between left and right
|
float angle = FMath::RandRange(recoilMaxAngleLeft, -recoilMaxAngleRight);
|
||||||
|
//randomg recoil vector angle between left and right
|
||||||
float recMag = recoilMagnitude * 252.f; //converting degrees to controller units
|
float recMag = recoilMagnitude * 252.f; //converting degrees to controller units
|
||||||
float tempMag = -FMath::RandRange(recMag * recoilMinMultiplier, recMag); // recoil magnitude
|
float tempMag = -FMath::RandRange(recMag * recoilMinMultiplier, recMag); // recoil magnitude
|
||||||
|
|
||||||
@ -131,11 +133,13 @@ void ABaseWeaponClass::nullSamples()
|
|||||||
float ABaseWeaponClass::GetRecoilPitch(float Amp, float Time)
|
float ABaseWeaponClass::GetRecoilPitch(float Amp, float Time)
|
||||||
{
|
{
|
||||||
//Using the trapez method and we are getting the surface under the curve, each trapezoid consist of square and right triangle
|
//Using the trapez method and we are getting the surface under the curve, each trapezoid consist of square and right triangle
|
||||||
float lower = recoilCurvez1 < Amp ? recoilCurvez1 : Amp; //get which point is common for both triangle and square of trapezoid
|
float lower = recoilCurvez1 < Amp ? recoilCurvez1 : Amp;
|
||||||
|
//get which point is common for both triangle and square of trapezoid
|
||||||
//lower point
|
//lower point
|
||||||
float mult = (Time - recoilCurvet) * lower; //getting surface of square
|
float mult = (Time - recoilCurvet) * lower; //getting surface of square
|
||||||
mult += (Time - recoilCurvet) * (Amp - recoilCurvez1) / 2.0f; //getting and adding surface of triangle
|
mult += (Time - recoilCurvet) * (Amp - recoilCurvez1) / 2.0f; //getting and adding surface of triangle
|
||||||
return (recoilResultPitch * mult) / playerControllerRef->InputPitchScale_DEPRECATED; //calculating and return recoil force for current frame
|
return (recoilResultPitch * mult) / playerControllerRef->InputPitchScale_DEPRECATED;
|
||||||
|
//calculating and return recoil force for current frame
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -184,8 +188,10 @@ void ABaseWeaponClass::Fire()
|
|||||||
if (GetWorldTimerManager().IsTimerActive(timerHandle)) return;
|
if (GetWorldTimerManager().IsTimerActive(timerHandle)) return;
|
||||||
|
|
||||||
//do damage fallof based off distance
|
//do damage fallof based off distance
|
||||||
UCameraComponent* CamComp = Cast<AEndlessVendettaCharacter>(GetWorld()->GetFirstPlayerController()->GetPawn())->GetFirstPersonCameraComponent();
|
UCameraComponent* CamComp = Cast<AEndlessVendettaCharacter>(GetWorld()->GetFirstPlayerController()->GetPawn())->
|
||||||
traceStart = Cast<USkeletalMeshComponent>(GetComponentByClass(USkeletalMeshComponent::StaticClass()))->GetSocketLocation("Muzzle");
|
GetFirstPersonCameraComponent();
|
||||||
|
traceStart = Cast<USkeletalMeshComponent>(GetComponentByClass(USkeletalMeshComponent::StaticClass()))->
|
||||||
|
GetSocketLocation("Muzzle");
|
||||||
traceEnd = CamComp->GetComponentLocation() + CamComp->GetForwardVector() * BulletDistance;
|
traceEnd = CamComp->GetComponentLocation() + CamComp->GetForwardVector() * BulletDistance;
|
||||||
FCollisionObjectQueryParams ObjectQueryParams;
|
FCollisionObjectQueryParams ObjectQueryParams;
|
||||||
ObjectQueryParams.AddObjectTypesToQuery(ECC_Pawn);
|
ObjectQueryParams.AddObjectTypesToQuery(ECC_Pawn);
|
||||||
@ -194,6 +200,7 @@ void ABaseWeaponClass::Fire()
|
|||||||
GetWorld()->LineTraceSingleByObjectType(outHit, traceStart, traceEnd, ObjectQueryParams, collisionParams);
|
GetWorld()->LineTraceSingleByObjectType(outHit, traceStart, traceEnd, ObjectQueryParams, collisionParams);
|
||||||
WeaponFired.Broadcast();
|
WeaponFired.Broadcast();
|
||||||
playerControllerRef->PlayerCameraManager->StartCameraShake(CameraShakeClass, 1);
|
playerControllerRef->PlayerCameraManager->StartCameraShake(CameraShakeClass, 1);
|
||||||
|
endlessVendettaChar->PawnNoiseEmitterComp->MakeNoise(endlessVendettaChar, 1, traceStart);
|
||||||
currentAmmoCount -= 1;
|
currentAmmoCount -= 1;
|
||||||
GenerateRecoilVector();
|
GenerateRecoilVector();
|
||||||
ClickDetectionTimer();
|
ClickDetectionTimer();
|
||||||
@ -220,7 +227,8 @@ void ABaseWeaponClass::Fire()
|
|||||||
{
|
{
|
||||||
endlessVendettaChar->SuccessfulHit();
|
endlessVendettaChar->SuccessfulHit();
|
||||||
}
|
}
|
||||||
Cast<AAICharacter>(outHit.GetActor())->TakeDamage(tempWeaponDamage, FPointDamageEvent(), GetWorld()->GetFirstPlayerController(), this);
|
Cast<AAICharacter>(outHit.GetActor())->TakeDamage(tempWeaponDamage, FPointDamageEvent(),
|
||||||
|
GetWorld()->GetFirstPlayerController(), this);
|
||||||
}
|
}
|
||||||
if (ATargetDummy* TargetDummy = Cast<ATargetDummy>(outHit.GetActor()))
|
if (ATargetDummy* TargetDummy = Cast<ATargetDummy>(outHit.GetActor()))
|
||||||
{
|
{
|
||||||
@ -229,7 +237,6 @@ void ABaseWeaponClass::Fire()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
HideNeedReloadUI();
|
HideNeedReloadUI();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ABaseWeaponClass::WeaponScopedFire()
|
void ABaseWeaponClass::WeaponScopedFire()
|
||||||
@ -286,7 +293,8 @@ void ABaseWeaponClass::SetupSilencerAttachment(UStaticMesh* SilencerMesh)
|
|||||||
GEngine->AddOnScreenDebugMessage(-1, 15.f, FColor::Red, TEXT("SETTING UP SILENCER ATTACHMENTS"));
|
GEngine->AddOnScreenDebugMessage(-1, 15.f, FColor::Red, TEXT("SETTING UP SILENCER ATTACHMENTS"));
|
||||||
FTransform EmptyTransform;
|
FTransform EmptyTransform;
|
||||||
|
|
||||||
USceneComponent* SilencerAttachmentClass = Cast<USceneComponent>(AddComponentByClass(USilencerAttachmentClass::StaticClass(), false, EmptyTransform, false));
|
USceneComponent* SilencerAttachmentClass = Cast<USceneComponent>(
|
||||||
|
AddComponentByClass(USilencerAttachmentClass::StaticClass(), false, EmptyTransform, false));
|
||||||
SilencerAttachmentClass->ComponentTags.Add(FName("AttachmentType"));
|
SilencerAttachmentClass->ComponentTags.Add(FName("AttachmentType"));
|
||||||
USkeletalMeshComponent* WeaponSkeletonMesh = FindComponentByClass<USkeletalMeshComponent>();
|
USkeletalMeshComponent* WeaponSkeletonMesh = FindComponentByClass<USkeletalMeshComponent>();
|
||||||
if (IsValid(SilencerAttachmentClass))
|
if (IsValid(SilencerAttachmentClass))
|
||||||
@ -294,16 +302,20 @@ void ABaseWeaponClass::SetupSilencerAttachment(UStaticMesh* SilencerMesh)
|
|||||||
if (IsValid(WeaponSkeletonMesh))
|
if (IsValid(WeaponSkeletonMesh))
|
||||||
{
|
{
|
||||||
//this handles giving the weapon the required component class/code
|
//this handles giving the weapon the required component class/code
|
||||||
SilencerAttachmentClass->AttachToComponent(WeaponSkeletonMesh, FAttachmentTransformRules::SnapToTargetIncludingScale, FName(TEXT("SilencerMeshSocket")));
|
SilencerAttachmentClass->AttachToComponent(WeaponSkeletonMesh,
|
||||||
|
FAttachmentTransformRules::SnapToTargetIncludingScale,
|
||||||
|
FName(TEXT("SilencerMeshSocket")));
|
||||||
UE_LOG(LogTemp, Display, TEXT("All Attachment is valid"));
|
UE_LOG(LogTemp, Display, TEXT("All Attachment is valid"));
|
||||||
//this makes it showup in editor for better debugging
|
//this makes it showup in editor for better debugging
|
||||||
SilencerAttachmentClass->CreationMethod = EComponentCreationMethod::Instance;
|
SilencerAttachmentClass->CreationMethod = EComponentCreationMethod::Instance;
|
||||||
SilencerAttachmentClass->RegisterComponent();
|
SilencerAttachmentClass->RegisterComponent();
|
||||||
//below handles seeing the physical attachment you selected
|
//below handles seeing the physical attachment you selected
|
||||||
UStaticMeshComponent* StaticMeshComp = NewObject<UStaticMeshComponent>(SilencerAttachmentClass, UStaticMeshComponent::StaticClass());
|
UStaticMeshComponent* StaticMeshComp = NewObject<UStaticMeshComponent>(
|
||||||
|
SilencerAttachmentClass, UStaticMeshComponent::StaticClass());
|
||||||
if (IsValid(StaticMeshComp))
|
if (IsValid(StaticMeshComp))
|
||||||
{
|
{
|
||||||
StaticMeshComp->AttachToComponent(SilencerAttachmentClass, FAttachmentTransformRules::SnapToTargetIncludingScale);
|
StaticMeshComp->AttachToComponent(SilencerAttachmentClass,
|
||||||
|
FAttachmentTransformRules::SnapToTargetIncludingScale);
|
||||||
StaticMeshComp->SetStaticMesh(SilencerMesh);
|
StaticMeshComp->SetStaticMesh(SilencerMesh);
|
||||||
StaticMeshComp->SetRelativeRotation(FRotator(0, 90, 0));
|
StaticMeshComp->SetRelativeRotation(FRotator(0, 90, 0));
|
||||||
StaticMeshComp->SetCollisionEnabled(ECollisionEnabled::NoCollision);
|
StaticMeshComp->SetCollisionEnabled(ECollisionEnabled::NoCollision);
|
||||||
@ -321,7 +333,8 @@ void ABaseWeaponClass::SetupExtendedMagAttachment(UStaticMesh* ExtendedMagMesh)
|
|||||||
GEngine->AddOnScreenDebugMessage(-1, 15.f, FColor::Red, TEXT("SETTING UP EXTENDEDMAG ATTACHMENTS"));
|
GEngine->AddOnScreenDebugMessage(-1, 15.f, FColor::Red, TEXT("SETTING UP EXTENDEDMAG ATTACHMENTS"));
|
||||||
FTransform EmptyTransform;
|
FTransform EmptyTransform;
|
||||||
|
|
||||||
USceneComponent* ExtendedMagAttachmentClass = Cast<USceneComponent>(AddComponentByClass(UExtendedMagAttachmentClass::StaticClass(), false, EmptyTransform, false));
|
USceneComponent* ExtendedMagAttachmentClass = Cast<USceneComponent>(
|
||||||
|
AddComponentByClass(UExtendedMagAttachmentClass::StaticClass(), false, EmptyTransform, false));
|
||||||
ExtendedMagAttachmentClass->ComponentTags.Add(FName("AttachmentType"));
|
ExtendedMagAttachmentClass->ComponentTags.Add(FName("AttachmentType"));
|
||||||
USkeletalMeshComponent* WeaponSkeletonMesh = FindComponentByClass<USkeletalMeshComponent>();
|
USkeletalMeshComponent* WeaponSkeletonMesh = FindComponentByClass<USkeletalMeshComponent>();
|
||||||
if (IsValid(ExtendedMagAttachmentClass))
|
if (IsValid(ExtendedMagAttachmentClass))
|
||||||
@ -329,16 +342,20 @@ void ABaseWeaponClass::SetupExtendedMagAttachment(UStaticMesh* ExtendedMagMesh)
|
|||||||
if (IsValid(WeaponSkeletonMesh))
|
if (IsValid(WeaponSkeletonMesh))
|
||||||
{
|
{
|
||||||
//this handles giving the weapon the required component class/code
|
//this handles giving the weapon the required component class/code
|
||||||
ExtendedMagAttachmentClass->AttachToComponent(WeaponSkeletonMesh, FAttachmentTransformRules::SnapToTargetIncludingScale, FName(TEXT("ExtendedMagSocket")));
|
ExtendedMagAttachmentClass->AttachToComponent(WeaponSkeletonMesh,
|
||||||
|
FAttachmentTransformRules::SnapToTargetIncludingScale,
|
||||||
|
FName(TEXT("ExtendedMagSocket")));
|
||||||
UE_LOG(LogTemp, Display, TEXT("All Attachment is valid"));
|
UE_LOG(LogTemp, Display, TEXT("All Attachment is valid"));
|
||||||
//this makes it showup in editor for better debugging
|
//this makes it showup in editor for better debugging
|
||||||
ExtendedMagAttachmentClass->CreationMethod = EComponentCreationMethod::Instance;
|
ExtendedMagAttachmentClass->CreationMethod = EComponentCreationMethod::Instance;
|
||||||
ExtendedMagAttachmentClass->RegisterComponent();
|
ExtendedMagAttachmentClass->RegisterComponent();
|
||||||
//below handles seeing the physical attachment you selected
|
//below handles seeing the physical attachment you selected
|
||||||
UStaticMeshComponent* StaticMeshComp = NewObject<UStaticMeshComponent>(ExtendedMagAttachmentClass, UStaticMeshComponent::StaticClass());
|
UStaticMeshComponent* StaticMeshComp = NewObject<UStaticMeshComponent>(
|
||||||
|
ExtendedMagAttachmentClass, UStaticMeshComponent::StaticClass());
|
||||||
if (IsValid(StaticMeshComp))
|
if (IsValid(StaticMeshComp))
|
||||||
{
|
{
|
||||||
StaticMeshComp->AttachToComponent(ExtendedMagAttachmentClass, FAttachmentTransformRules::SnapToTargetIncludingScale);
|
StaticMeshComp->AttachToComponent(ExtendedMagAttachmentClass,
|
||||||
|
FAttachmentTransformRules::SnapToTargetIncludingScale);
|
||||||
StaticMeshComp->SetStaticMesh(ExtendedMagMesh);
|
StaticMeshComp->SetStaticMesh(ExtendedMagMesh);
|
||||||
StaticMeshComp->SetRelativeRotation(FRotator(0, 180, 0));
|
StaticMeshComp->SetRelativeRotation(FRotator(0, 180, 0));
|
||||||
StaticMeshComp->SetCollisionEnabled(ECollisionEnabled::NoCollision);
|
StaticMeshComp->SetCollisionEnabled(ECollisionEnabled::NoCollision);
|
||||||
@ -356,7 +373,8 @@ void ABaseWeaponClass::SetupGripAttachment(UStaticMesh* GripMesh)
|
|||||||
GEngine->AddOnScreenDebugMessage(-1, 15.f, FColor::Red, TEXT("SETTING UP GRIP ATTACHMENTS"));
|
GEngine->AddOnScreenDebugMessage(-1, 15.f, FColor::Red, TEXT("SETTING UP GRIP ATTACHMENTS"));
|
||||||
FTransform EmptyTransform;
|
FTransform EmptyTransform;
|
||||||
|
|
||||||
USceneComponent* GripAttachmentClass = Cast<USceneComponent>(AddComponentByClass(UGripAttachmentClass::StaticClass(), false, EmptyTransform, false));
|
USceneComponent* GripAttachmentClass = Cast<USceneComponent>(
|
||||||
|
AddComponentByClass(UGripAttachmentClass::StaticClass(), false, EmptyTransform, false));
|
||||||
GripAttachmentClass->ComponentTags.Add(FName("AttachmentType"));
|
GripAttachmentClass->ComponentTags.Add(FName("AttachmentType"));
|
||||||
USkeletalMeshComponent* WeaponSkeletonMesh = FindComponentByClass<USkeletalMeshComponent>();
|
USkeletalMeshComponent* WeaponSkeletonMesh = FindComponentByClass<USkeletalMeshComponent>();
|
||||||
if (IsValid(GripAttachmentClass))
|
if (IsValid(GripAttachmentClass))
|
||||||
@ -364,16 +382,20 @@ void ABaseWeaponClass::SetupGripAttachment(UStaticMesh* GripMesh)
|
|||||||
if (IsValid(WeaponSkeletonMesh))
|
if (IsValid(WeaponSkeletonMesh))
|
||||||
{
|
{
|
||||||
//this handles giving the weapon the required component class/code
|
//this handles giving the weapon the required component class/code
|
||||||
GripAttachmentClass->AttachToComponent(WeaponSkeletonMesh, FAttachmentTransformRules::SnapToTargetIncludingScale, FName(TEXT("GripMeshSocket")));
|
GripAttachmentClass->AttachToComponent(WeaponSkeletonMesh,
|
||||||
|
FAttachmentTransformRules::SnapToTargetIncludingScale,
|
||||||
|
FName(TEXT("GripMeshSocket")));
|
||||||
UE_LOG(LogTemp, Display, TEXT("All Attachment is valid"));
|
UE_LOG(LogTemp, Display, TEXT("All Attachment is valid"));
|
||||||
//this makes it showup in editor for better debugging
|
//this makes it showup in editor for better debugging
|
||||||
GripAttachmentClass->CreationMethod = EComponentCreationMethod::Instance;
|
GripAttachmentClass->CreationMethod = EComponentCreationMethod::Instance;
|
||||||
GripAttachmentClass->RegisterComponent();
|
GripAttachmentClass->RegisterComponent();
|
||||||
//below handles seeing the physical attachment you selected
|
//below handles seeing the physical attachment you selected
|
||||||
UStaticMeshComponent* StaticMeshComp = NewObject<UStaticMeshComponent>(GripAttachmentClass, UStaticMeshComponent::StaticClass());
|
UStaticMeshComponent* StaticMeshComp = NewObject<UStaticMeshComponent>(
|
||||||
|
GripAttachmentClass, UStaticMeshComponent::StaticClass());
|
||||||
if (IsValid(StaticMeshComp))
|
if (IsValid(StaticMeshComp))
|
||||||
{
|
{
|
||||||
StaticMeshComp->AttachToComponent(GripAttachmentClass, FAttachmentTransformRules::SnapToTargetIncludingScale);
|
StaticMeshComp->AttachToComponent(GripAttachmentClass,
|
||||||
|
FAttachmentTransformRules::SnapToTargetIncludingScale);
|
||||||
StaticMeshComp->SetStaticMesh(GripMesh);
|
StaticMeshComp->SetStaticMesh(GripMesh);
|
||||||
StaticMeshComp->SetRelativeRotation(FRotator(0, 0, 0));
|
StaticMeshComp->SetRelativeRotation(FRotator(0, 0, 0));
|
||||||
StaticMeshComp->SetCollisionEnabled(ECollisionEnabled::NoCollision);
|
StaticMeshComp->SetCollisionEnabled(ECollisionEnabled::NoCollision);
|
||||||
@ -387,5 +409,4 @@ void ABaseWeaponClass::SetupGripAttachment(UStaticMesh* GripMesh)
|
|||||||
|
|
||||||
void ABaseWeaponClass::RemoveAllAttachments()
|
void ABaseWeaponClass::RemoveAllAttachments()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
#include "WeaponItemClass.h"
|
#include "WeaponItemClass.h"
|
||||||
#include "Components/ArrowComponent.h"
|
#include "Components/ArrowComponent.h"
|
||||||
|
#include "Components/PawnNoiseEmitterComponent.h"
|
||||||
#include "Kismet/KismetMathLibrary.h"
|
#include "Kismet/KismetMathLibrary.h"
|
||||||
#include "EndlessVendetta/InteractionInterface.h"
|
#include "EndlessVendetta/InteractionInterface.h"
|
||||||
#include "Engine/EngineTypes.h"
|
#include "Engine/EngineTypes.h"
|
||||||
@ -50,6 +51,7 @@ protected:
|
|||||||
public:
|
public:
|
||||||
// Called every frame
|
// Called every frame
|
||||||
virtual void Tick(float DeltaTime) override;
|
virtual void Tick(float DeltaTime) override;
|
||||||
|
|
||||||
void ReloadTimer();
|
void ReloadTimer();
|
||||||
|
|
||||||
float currentPitch;
|
float currentPitch;
|
||||||
|
Loading…
Reference in New Issue
Block a user