From 395ea7baa475b380b84c3422378116843ba3ed1c Mon Sep 17 00:00:00 2001 From: PHILIP WHITE Date: Wed, 4 Oct 2023 01:24:03 +0100 Subject: [PATCH 1/5] Update Basic Enemy Behaviour Tree to Patrol --- EndlessVendetta/Content/AI/Enemy/Basic/BB_BasicEnemy.uasset | 4 ++-- EndlessVendetta/Content/AI/Enemy/Basic/BT_BasicEnemy.uasset | 4 ++-- .../ReconGadgets/VisionLink/VisionLinkViewPortBG.uasset | 4 ++-- .../Gadgets/ReconGadgets/VisionLink/WatchFaceBGImage.uasset | 4 ++-- .../Source/EndlessVendetta/AI/BTTask_AttackPlayer.cpp | 1 + 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/EndlessVendetta/Content/AI/Enemy/Basic/BB_BasicEnemy.uasset b/EndlessVendetta/Content/AI/Enemy/Basic/BB_BasicEnemy.uasset index 83745345..56819b9d 100644 --- a/EndlessVendetta/Content/AI/Enemy/Basic/BB_BasicEnemy.uasset +++ b/EndlessVendetta/Content/AI/Enemy/Basic/BB_BasicEnemy.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:73bd053142b2dc9fb78973a96805b66270a7f976a36986ef658580a9d2ba75a7 -size 4123 +oid sha256:d175544d93e03c9c35e6fa9e17caa58f91fa9c2227be1f62ddc9234b095e8d46 +size 4420 diff --git a/EndlessVendetta/Content/AI/Enemy/Basic/BT_BasicEnemy.uasset b/EndlessVendetta/Content/AI/Enemy/Basic/BT_BasicEnemy.uasset index 2b5f26e3..63d6a5f9 100644 --- a/EndlessVendetta/Content/AI/Enemy/Basic/BT_BasicEnemy.uasset +++ b/EndlessVendetta/Content/AI/Enemy/Basic/BT_BasicEnemy.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8cc72d5c792915b0c3002c85fb1c1fc24fcf3a88d4fa85200d1d8b04f483f4ef -size 15107 +oid sha256:7edfafa0555092e33fe013a8130878ffa4cc97c34d1cd617bc71bb03bd5d194c +size 19535 diff --git a/EndlessVendetta/Content/Gadgets/ReconGadgets/VisionLink/VisionLinkViewPortBG.uasset b/EndlessVendetta/Content/Gadgets/ReconGadgets/VisionLink/VisionLinkViewPortBG.uasset index c31bec52..47adc792 100644 --- a/EndlessVendetta/Content/Gadgets/ReconGadgets/VisionLink/VisionLinkViewPortBG.uasset +++ b/EndlessVendetta/Content/Gadgets/ReconGadgets/VisionLink/VisionLinkViewPortBG.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fd673d7b47c8310bbae47b765919076a4b73cc20813122a3904f97950973435c -size 45518 +oid sha256:b2a0267c4ceb00701b79abff52a736e5a2a001237b1000565794517852d0f647 +size 45613 diff --git a/EndlessVendetta/Content/Gadgets/ReconGadgets/VisionLink/WatchFaceBGImage.uasset b/EndlessVendetta/Content/Gadgets/ReconGadgets/VisionLink/WatchFaceBGImage.uasset index d05f935a..0daf9a11 100644 --- a/EndlessVendetta/Content/Gadgets/ReconGadgets/VisionLink/WatchFaceBGImage.uasset +++ b/EndlessVendetta/Content/Gadgets/ReconGadgets/VisionLink/WatchFaceBGImage.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:afbeeb63e797939650edcf947c6d364fc2372b04290963f53cddc2025d7e4efa -size 19748 +oid sha256:da887885cdc8d543e4992f2e9e543c974427ce77414d85c5b1faa92bf13c2357 +size 19843 diff --git a/EndlessVendetta/Source/EndlessVendetta/AI/BTTask_AttackPlayer.cpp b/EndlessVendetta/Source/EndlessVendetta/AI/BTTask_AttackPlayer.cpp index 07db4b83..74b01095 100644 --- a/EndlessVendetta/Source/EndlessVendetta/AI/BTTask_AttackPlayer.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/AI/BTTask_AttackPlayer.cpp @@ -19,6 +19,7 @@ EBTNodeResult::Type UBTTask_AttackPlayer::ExecuteTask(UBehaviorTreeComponent& Ow FVector const Origin = AIController->GetPawn()->GetActorLocation(); FVector const PlayerLocation = Blackboard->GetValueAsVector("TargetLocation"); DrawDebugLine(GetWorld(), Origin, PlayerLocation, FColor::Green, false, 1.f, 0, 1.f); + FinishLatentTask(OwnerComp, EBTNodeResult::Succeeded); return EBTNodeResult::Succeeded; } From e13e6d1bacac5f0d58f26a74f47f5653ca3680d3 Mon Sep 17 00:00:00 2001 From: PHILIP WHITE Date: Wed, 4 Oct 2023 01:49:10 +0100 Subject: [PATCH 2/5] Update Basic Enemy AI to Not Overlap with Friendlies --- .../Content/AI/Enemy/Basic/BP_BasicEnemyCharacter.uasset | 4 ++-- EndlessVendetta/Content/AI/Enemy/Basic/EQSB_Enemy.uasset | 3 +++ .../Content/AI/Enemy/Basic/EQS_EnemyFindCover.uasset | 4 ++-- .../Levels/EnemyAITest/B/AZ/GX8EY01G00J28SE17R0FJV.uasset | 4 ++-- .../Levels/EnemyAITest/E/PJ/BY6E8JXZSRNMAW3DFHRHRJ.uasset | 3 +++ .../Source/EndlessVendetta/AI/AI_EnemyController.cpp | 2 +- 6 files changed, 13 insertions(+), 7 deletions(-) create mode 100644 EndlessVendetta/Content/AI/Enemy/Basic/EQSB_Enemy.uasset create mode 100644 EndlessVendetta/Content/__ExternalActors__/Levels/EnemyAITest/E/PJ/BY6E8JXZSRNMAW3DFHRHRJ.uasset diff --git a/EndlessVendetta/Content/AI/Enemy/Basic/BP_BasicEnemyCharacter.uasset b/EndlessVendetta/Content/AI/Enemy/Basic/BP_BasicEnemyCharacter.uasset index ee381207..894c9059 100644 --- a/EndlessVendetta/Content/AI/Enemy/Basic/BP_BasicEnemyCharacter.uasset +++ b/EndlessVendetta/Content/AI/Enemy/Basic/BP_BasicEnemyCharacter.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f5a7fcd4447476e36ad777f4db7b6e5898905b85f6fa1bb8b193a98ec26066dc -size 32684 +oid sha256:0cce34a40f6aed425749f0c271aa6ba31b8bfea2ffafb3446559e374f0676b4b +size 32990 diff --git a/EndlessVendetta/Content/AI/Enemy/Basic/EQSB_Enemy.uasset b/EndlessVendetta/Content/AI/Enemy/Basic/EQSB_Enemy.uasset new file mode 100644 index 00000000..436112d7 --- /dev/null +++ b/EndlessVendetta/Content/AI/Enemy/Basic/EQSB_Enemy.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:978aab3035ae3876cef293be990751ff0a4966d407f62262698a530862855320 +size 19419 diff --git a/EndlessVendetta/Content/AI/Enemy/Basic/EQS_EnemyFindCover.uasset b/EndlessVendetta/Content/AI/Enemy/Basic/EQS_EnemyFindCover.uasset index 31dcfb1a..d8fa1226 100644 --- a/EndlessVendetta/Content/AI/Enemy/Basic/EQS_EnemyFindCover.uasset +++ b/EndlessVendetta/Content/AI/Enemy/Basic/EQS_EnemyFindCover.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fcf182403f772d060b1f0c2997671ec13f6f6d32dd3817841a4f612ad87dff81 -size 10974 +oid sha256:115f268dcbca6bf144baa4bb0572ea023da1ffd074ae6e7dd445bd9f4cba645c +size 11772 diff --git a/EndlessVendetta/Content/__ExternalActors__/Levels/EnemyAITest/B/AZ/GX8EY01G00J28SE17R0FJV.uasset b/EndlessVendetta/Content/__ExternalActors__/Levels/EnemyAITest/B/AZ/GX8EY01G00J28SE17R0FJV.uasset index d4567926..60451f7e 100644 --- a/EndlessVendetta/Content/__ExternalActors__/Levels/EnemyAITest/B/AZ/GX8EY01G00J28SE17R0FJV.uasset +++ b/EndlessVendetta/Content/__ExternalActors__/Levels/EnemyAITest/B/AZ/GX8EY01G00J28SE17R0FJV.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bcadae2018380b51ecd7bea3850566c6b0013ea6acb8ad1cdb8a0f4307fbc65c -size 5230 +oid sha256:c7cb8357ffc004ebe77fee2fef237bde524e9a64befca078884785e9762c654c +size 5440 diff --git a/EndlessVendetta/Content/__ExternalActors__/Levels/EnemyAITest/E/PJ/BY6E8JXZSRNMAW3DFHRHRJ.uasset b/EndlessVendetta/Content/__ExternalActors__/Levels/EnemyAITest/E/PJ/BY6E8JXZSRNMAW3DFHRHRJ.uasset new file mode 100644 index 00000000..93f0eeb7 --- /dev/null +++ b/EndlessVendetta/Content/__ExternalActors__/Levels/EnemyAITest/E/PJ/BY6E8JXZSRNMAW3DFHRHRJ.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7b6617a297705f0f5de3dd5a3a85b65bb6984399bbacc3863b84e88df64cd01e +size 5115 diff --git a/EndlessVendetta/Source/EndlessVendetta/AI/AI_EnemyController.cpp b/EndlessVendetta/Source/EndlessVendetta/AI/AI_EnemyController.cpp index 94ef8372..6e0b0ec2 100644 --- a/EndlessVendetta/Source/EndlessVendetta/AI/AI_EnemyController.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/AI/AI_EnemyController.cpp @@ -15,7 +15,7 @@ AAI_EnemyController::AAI_EnemyController(FObjectInitializer const& ObjectInitial { // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it. PrimaryActorTick.bCanEverTick = true; - + SetGenericTeamId(FGenericTeamId(1)); SetupPerceptionSystem(); } From 44e25b8472dfee24766b1d1ebb6d6a8849e40d26 Mon Sep 17 00:00:00 2001 From: PHILIP WHITE Date: Wed, 4 Oct 2023 02:25:27 +0100 Subject: [PATCH 3/5] Add Companion Character for Generic Base --- EndlessVendetta/Content/AI/EQSB_Enemy.uasset | 3 + EndlessVendetta/Content/AI/EQSB_Player.uasset | 3 + EndlessVendetta/Content/AI/EQS_Test.uasset | 3 + .../Content/AI/Enemy/Basic/EQSB_Enemy.uasset | 3 - .../Content/AI/Enemy/Basic/EQSB_Player.uasset | 3 - .../AI/Enemy/Basic/EQS_EnemyFindCover.uasset | 4 +- .../Content/AI/Enemy/Basic/EQS_Test.uasset | 3 - .../B/AZ/GX8EY01G00J28SE17R0FJV.uasset | 4 +- .../E/PJ/BY6E8JXZSRNMAW3DFHRHRJ.uasset | 4 +- .../AI/AI_CompanionController.cpp | 85 +++++++++++++++++++ .../AI/AI_CompanionController.h | 36 ++++++++ .../EndlessVendetta/AI/AI_EnemyController.cpp | 2 +- .../EndlessVendetta/AI/CompanionCharacter.cpp | 50 +++++++++++ .../EndlessVendetta/AI/CompanionCharacter.h | 38 +++++++++ 14 files changed, 225 insertions(+), 16 deletions(-) create mode 100644 EndlessVendetta/Content/AI/EQSB_Enemy.uasset create mode 100644 EndlessVendetta/Content/AI/EQSB_Player.uasset create mode 100644 EndlessVendetta/Content/AI/EQS_Test.uasset delete mode 100644 EndlessVendetta/Content/AI/Enemy/Basic/EQSB_Enemy.uasset delete mode 100644 EndlessVendetta/Content/AI/Enemy/Basic/EQSB_Player.uasset delete mode 100644 EndlessVendetta/Content/AI/Enemy/Basic/EQS_Test.uasset create mode 100644 EndlessVendetta/Source/EndlessVendetta/AI/AI_CompanionController.cpp create mode 100644 EndlessVendetta/Source/EndlessVendetta/AI/AI_CompanionController.h create mode 100644 EndlessVendetta/Source/EndlessVendetta/AI/CompanionCharacter.cpp create mode 100644 EndlessVendetta/Source/EndlessVendetta/AI/CompanionCharacter.h diff --git a/EndlessVendetta/Content/AI/EQSB_Enemy.uasset b/EndlessVendetta/Content/AI/EQSB_Enemy.uasset new file mode 100644 index 00000000..39744dd3 --- /dev/null +++ b/EndlessVendetta/Content/AI/EQSB_Enemy.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d9fafb5ea724311d8a706eb8f12493e004ab343735895a80be1811e2caa95f64 +size 18966 diff --git a/EndlessVendetta/Content/AI/EQSB_Player.uasset b/EndlessVendetta/Content/AI/EQSB_Player.uasset new file mode 100644 index 00000000..65abdba4 --- /dev/null +++ b/EndlessVendetta/Content/AI/EQSB_Player.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:92ebb9e1566806ef68b6d274fa0a1ebd629b71d24c87c36024db0720213cdc8b +size 17638 diff --git a/EndlessVendetta/Content/AI/EQS_Test.uasset b/EndlessVendetta/Content/AI/EQS_Test.uasset new file mode 100644 index 00000000..d6184a2f --- /dev/null +++ b/EndlessVendetta/Content/AI/EQS_Test.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0d7fcae1638292db5530edb7c1a864ecfedc45f339b8bbf85f86a78754f1ac4a +size 24150 diff --git a/EndlessVendetta/Content/AI/Enemy/Basic/EQSB_Enemy.uasset b/EndlessVendetta/Content/AI/Enemy/Basic/EQSB_Enemy.uasset deleted file mode 100644 index 436112d7..00000000 --- a/EndlessVendetta/Content/AI/Enemy/Basic/EQSB_Enemy.uasset +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:978aab3035ae3876cef293be990751ff0a4966d407f62262698a530862855320 -size 19419 diff --git a/EndlessVendetta/Content/AI/Enemy/Basic/EQSB_Player.uasset b/EndlessVendetta/Content/AI/Enemy/Basic/EQSB_Player.uasset deleted file mode 100644 index a1e8f59b..00000000 --- a/EndlessVendetta/Content/AI/Enemy/Basic/EQSB_Player.uasset +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:4da78b93d151ff916a8b62f09f88ce28b8efeb76a9d1d468a6e56f95d50a711d -size 17987 diff --git a/EndlessVendetta/Content/AI/Enemy/Basic/EQS_EnemyFindCover.uasset b/EndlessVendetta/Content/AI/Enemy/Basic/EQS_EnemyFindCover.uasset index d8fa1226..ae3f1455 100644 --- a/EndlessVendetta/Content/AI/Enemy/Basic/EQS_EnemyFindCover.uasset +++ b/EndlessVendetta/Content/AI/Enemy/Basic/EQS_EnemyFindCover.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:115f268dcbca6bf144baa4bb0572ea023da1ffd074ae6e7dd445bd9f4cba645c -size 11772 +oid sha256:9e53cfdf2c62f71a8e9cf4533df7a333c33ddec1b9b830b7c85434c2dad50b3c +size 11760 diff --git a/EndlessVendetta/Content/AI/Enemy/Basic/EQS_Test.uasset b/EndlessVendetta/Content/AI/Enemy/Basic/EQS_Test.uasset deleted file mode 100644 index eb8c4663..00000000 --- a/EndlessVendetta/Content/AI/Enemy/Basic/EQS_Test.uasset +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:5f5b2ddf1641fad4bf9b75104089070dd382ab3b630619aa5cbb0fb19e215f22 -size 22729 diff --git a/EndlessVendetta/Content/__ExternalActors__/Levels/EnemyAITest/B/AZ/GX8EY01G00J28SE17R0FJV.uasset b/EndlessVendetta/Content/__ExternalActors__/Levels/EnemyAITest/B/AZ/GX8EY01G00J28SE17R0FJV.uasset index 60451f7e..b1ec8842 100644 --- a/EndlessVendetta/Content/__ExternalActors__/Levels/EnemyAITest/B/AZ/GX8EY01G00J28SE17R0FJV.uasset +++ b/EndlessVendetta/Content/__ExternalActors__/Levels/EnemyAITest/B/AZ/GX8EY01G00J28SE17R0FJV.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c7cb8357ffc004ebe77fee2fef237bde524e9a64befca078884785e9762c654c -size 5440 +oid sha256:b846a25931a6e0277f004c0f41c52eb17b7ea951697783592186c6cb01904bfc +size 5216 diff --git a/EndlessVendetta/Content/__ExternalActors__/Levels/EnemyAITest/E/PJ/BY6E8JXZSRNMAW3DFHRHRJ.uasset b/EndlessVendetta/Content/__ExternalActors__/Levels/EnemyAITest/E/PJ/BY6E8JXZSRNMAW3DFHRHRJ.uasset index 93f0eeb7..4abdf431 100644 --- a/EndlessVendetta/Content/__ExternalActors__/Levels/EnemyAITest/E/PJ/BY6E8JXZSRNMAW3DFHRHRJ.uasset +++ b/EndlessVendetta/Content/__ExternalActors__/Levels/EnemyAITest/E/PJ/BY6E8JXZSRNMAW3DFHRHRJ.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7b6617a297705f0f5de3dd5a3a85b65bb6984399bbacc3863b84e88df64cd01e -size 5115 +oid sha256:cfb0f1718ab71a979c83b7884652cb8b9a757abf7c2e17c1d3b356f1ef4228f7 +size 5313 diff --git a/EndlessVendetta/Source/EndlessVendetta/AI/AI_CompanionController.cpp b/EndlessVendetta/Source/EndlessVendetta/AI/AI_CompanionController.cpp new file mode 100644 index 00000000..5ca23fe3 --- /dev/null +++ b/EndlessVendetta/Source/EndlessVendetta/AI/AI_CompanionController.cpp @@ -0,0 +1,85 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "AI_CompanionController.h" + +#include "AI_EnemyController.h" +#include "CompanionCharacter.h" +#include "EndlessVendetta/EndlessVendettaCharacter.h" +#include "Perception/AIPerceptionComponent.h" +#include "Perception/AISenseConfig_Sight.h" + + +AAI_CompanionController::AAI_CompanionController(FObjectInitializer const& ObjectInitializer) +{ + // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it. + PrimaryActorTick.bCanEverTick = true; + AAIController::SetGenericTeamId(FGenericTeamId(0)); + SetupPerceptionSystem(); +} + +// Called when the game starts or when spawned +void AAI_CompanionController::BeginPlay() +{ + Super::BeginPlay(); +} + +void AAI_CompanionController::OnPossess(APawn* InPawn) +{ + Super::OnPossess(InPawn); + if (const ACompanionCharacter* CompanionCharacter = Cast(InPawn)) + { + if (UBehaviorTree* const BehaviorTree = CompanionCharacter->GetBehaviorTree()) + { + UBlackboardComponent* TempBlackboardPtr; + UseBlackboard(BehaviorTree->BlackboardAsset, TempBlackboardPtr); + Blackboard = TempBlackboardPtr; + RunBehaviorTree(BehaviorTree); + } + } +} + +// Called every frame +void AAI_CompanionController::Tick(float DeltaTime) +{ + Super::Tick(DeltaTime); +} + +void AAI_CompanionController::SetupPerceptionSystem() +{ + SightConfig = CreateDefaultSubobject(TEXT("Sight Config")); + if (IsValid(SightConfig)) + { + SetPerceptionComponent(*CreateDefaultSubobject(TEXT("Perception Component"))); + SightConfig->SightRadius = 2000.0f; + SightConfig->LoseSightRadius = 2100.0f; + SightConfig->PeripheralVisionAngleDegrees = 70.0f; + SightConfig->SetMaxAge(20.0f); + SightConfig->AutoSuccessRangeFromLastSeenLocation = 520.0f; + SightConfig->DetectionByAffiliation.bDetectEnemies = true; + SightConfig->DetectionByAffiliation.bDetectFriendlies = true; + SightConfig->DetectionByAffiliation.bDetectNeutrals = true; + GetPerceptionComponent()->SetDominantSense(*SightConfig->GetSenseImplementation()); + GetPerceptionComponent()->OnTargetPerceptionUpdated.AddDynamic(this, &AAI_CompanionController::OnTargetPerceptionUpdated); + GetPerceptionComponent()->ConfigureSense(*SightConfig); + } +} + +void AAI_CompanionController::OnTargetPerceptionUpdated(AActor* Actor, FAIStimulus const Stimulus) +{ + if (AEndlessVendettaCharacter* const PlayerCharacter = Cast(Actor)) + { + // if (Stimulus.WasSuccessfullySensed()) + // { + // GetBlackboardComponent()->SetValueAsObject("TargetPlayer", Actor); + // GetBlackboardComponent()->SetValueAsVector("TargetLocation", Stimulus.StimulusLocation); + // GetBlackboardComponent()->SetValueAsBool("CanSeePlayer", true); + // } + // else + // { + // GetBlackboardComponent()->ClearValue("TargetActor"); + // GetBlackboardComponent()->ClearValue("TargetLocation"); + // GetBlackboardComponent()->SetValueAsBool("CanSeePlayer", false); + // } + } +} diff --git a/EndlessVendetta/Source/EndlessVendetta/AI/AI_CompanionController.h b/EndlessVendetta/Source/EndlessVendetta/AI/AI_CompanionController.h new file mode 100644 index 00000000..3fb57dc2 --- /dev/null +++ b/EndlessVendetta/Source/EndlessVendetta/AI/AI_CompanionController.h @@ -0,0 +1,36 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "AIController.h" +#include "AI_CompanionController.generated.h" + +struct FAIStimulus; + +UCLASS() +class ENDLESSVENDETTA_API AAI_CompanionController : public AAIController +{ + GENERATED_BODY() + +public: + // Sets default values for this actor's properties + explicit AAI_CompanionController(FObjectInitializer const& ObjectInitializer); + +protected: + // Called when the game starts or when spawned + virtual void BeginPlay() override; + virtual void OnPossess(APawn* InPawn) override; + +public: + // Called every frame + virtual void Tick(float DeltaTime) override; + +private: + class UAISenseConfig_Sight* SightConfig; + void SetupPerceptionSystem(); + + UFUNCTION() + void OnTargetPerceptionUpdated(AActor* Actor, FAIStimulus const Stimulus); + +}; diff --git a/EndlessVendetta/Source/EndlessVendetta/AI/AI_EnemyController.cpp b/EndlessVendetta/Source/EndlessVendetta/AI/AI_EnemyController.cpp index 6e0b0ec2..f29f3d4a 100644 --- a/EndlessVendetta/Source/EndlessVendetta/AI/AI_EnemyController.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/AI/AI_EnemyController.cpp @@ -15,7 +15,7 @@ AAI_EnemyController::AAI_EnemyController(FObjectInitializer const& ObjectInitial { // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it. PrimaryActorTick.bCanEverTick = true; - SetGenericTeamId(FGenericTeamId(1)); + AAIController::SetGenericTeamId(FGenericTeamId(1)); SetupPerceptionSystem(); } diff --git a/EndlessVendetta/Source/EndlessVendetta/AI/CompanionCharacter.cpp b/EndlessVendetta/Source/EndlessVendetta/AI/CompanionCharacter.cpp new file mode 100644 index 00000000..5475ee04 --- /dev/null +++ b/EndlessVendetta/Source/EndlessVendetta/AI/CompanionCharacter.cpp @@ -0,0 +1,50 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "CompanionCharacter.h" + +#include "Perception/AIPerceptionStimuliSourceComponent.h" +#include "Perception/AISense_Sight.h" + + +// Sets default values +ACompanionCharacter::ACompanionCharacter() +{ + // Set this character to call Tick() every frame. You can turn this off to improve performance if you don't need it. + PrimaryActorTick.bCanEverTick = true; +} + +// Called when the game starts or when spawned +void ACompanionCharacter::BeginPlay() +{ + Super::BeginPlay(); + +} + +// Called every frame +void ACompanionCharacter::Tick(float DeltaTime) +{ + Super::Tick(DeltaTime); +} + +// Called to bind functionality to input +void ACompanionCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) +{ + Super::SetupPlayerInputComponent(PlayerInputComponent); +} + +UBehaviorTree* ACompanionCharacter::GetBehaviorTree() const +{ + return BehaviorTree; +} + +void ACompanionCharacter::SetupStimuliSourceComponent() +{ + StimuliSourceComponent = CreateDefaultSubobject(TEXT("Stimuli Source Component")); + if (IsValid(StimuliSourceComponent)) + { + StimuliSourceComponent->RegisterForSense(TSubclassOf()); + StimuliSourceComponent->RegisterWithPerceptionSystem(); + } +} + diff --git a/EndlessVendetta/Source/EndlessVendetta/AI/CompanionCharacter.h b/EndlessVendetta/Source/EndlessVendetta/AI/CompanionCharacter.h new file mode 100644 index 00000000..0a484bbc --- /dev/null +++ b/EndlessVendetta/Source/EndlessVendetta/AI/CompanionCharacter.h @@ -0,0 +1,38 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "BehaviorTree/BehaviorTree.h" +#include "GameFramework/Character.h" +#include "CompanionCharacter.generated.h" + +UCLASS() +class ENDLESSVENDETTA_API ACompanionCharacter : public ACharacter +{ + GENERATED_BODY() + +public: + // Sets default values for this character's properties + ACompanionCharacter(); + +protected: + // Called when the game starts or when spawned + virtual void BeginPlay() override; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "AI") + UBehaviorTree* BehaviorTree; +public: + // Called every frame + virtual void Tick(float DeltaTime) override; + + // Called to bind functionality to input + virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override; + + UFUNCTION(BlueprintCallable, Category = "AI") + UBehaviorTree* GetBehaviorTree() const; + +private: + class UAIPerceptionStimuliSourceComponent* StimuliSourceComponent; + void SetupStimuliSourceComponent(); +}; From c69b61c65042315973cea0baf7d75c524ea5e46c Mon Sep 17 00:00:00 2001 From: PHILIP WHITE Date: Wed, 4 Oct 2023 02:26:11 +0100 Subject: [PATCH 4/5] Add EQS, BP Companion Character for Companion Pathing --- .../Content/AI/Companion/Generic/BB_GenericCompanion.uasset | 3 +++ .../Content/AI/Companion/Generic/BT_GenericCompanion.uasset | 3 +++ .../Content/AI/Companion/Generic/CompanionCharacter.uasset | 3 +++ .../AI/Companion/Generic/EQS_FindCoverNearPlayer.uasset | 3 +++ .../Levels/EnemyAITest/A/UU/P4XZ4FDZKD5IXIWK3JDDDK.uasset | 3 +++ .../Levels/EnemyAITest/C/U2/RJOME4RGCN15IGVOBN2IPY.uasset | 3 +++ 6 files changed, 18 insertions(+) create mode 100644 EndlessVendetta/Content/AI/Companion/Generic/BB_GenericCompanion.uasset create mode 100644 EndlessVendetta/Content/AI/Companion/Generic/BT_GenericCompanion.uasset create mode 100644 EndlessVendetta/Content/AI/Companion/Generic/CompanionCharacter.uasset create mode 100644 EndlessVendetta/Content/AI/Companion/Generic/EQS_FindCoverNearPlayer.uasset create mode 100644 EndlessVendetta/Content/__ExternalActors__/Levels/EnemyAITest/A/UU/P4XZ4FDZKD5IXIWK3JDDDK.uasset create mode 100644 EndlessVendetta/Content/__ExternalActors__/Levels/EnemyAITest/C/U2/RJOME4RGCN15IGVOBN2IPY.uasset diff --git a/EndlessVendetta/Content/AI/Companion/Generic/BB_GenericCompanion.uasset b/EndlessVendetta/Content/AI/Companion/Generic/BB_GenericCompanion.uasset new file mode 100644 index 00000000..38798a46 --- /dev/null +++ b/EndlessVendetta/Content/AI/Companion/Generic/BB_GenericCompanion.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:eaedcee2488826c0cbd4c69646da5a3f0b12d6815971805e9ecfbbdf4bc1a2ce +size 2258 diff --git a/EndlessVendetta/Content/AI/Companion/Generic/BT_GenericCompanion.uasset b/EndlessVendetta/Content/AI/Companion/Generic/BT_GenericCompanion.uasset new file mode 100644 index 00000000..6fb83025 --- /dev/null +++ b/EndlessVendetta/Content/AI/Companion/Generic/BT_GenericCompanion.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0a51c6e09ee9b960ab6f095ef348e94881cf58c2594520303790718cdbd2b12d +size 10480 diff --git a/EndlessVendetta/Content/AI/Companion/Generic/CompanionCharacter.uasset b/EndlessVendetta/Content/AI/Companion/Generic/CompanionCharacter.uasset new file mode 100644 index 00000000..1d6453bf --- /dev/null +++ b/EndlessVendetta/Content/AI/Companion/Generic/CompanionCharacter.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e98da72016a1ef89567571563bb8ddcb251370a7ae7f39b5a0ef17741de9154d +size 32421 diff --git a/EndlessVendetta/Content/AI/Companion/Generic/EQS_FindCoverNearPlayer.uasset b/EndlessVendetta/Content/AI/Companion/Generic/EQS_FindCoverNearPlayer.uasset new file mode 100644 index 00000000..6f4e7c66 --- /dev/null +++ b/EndlessVendetta/Content/AI/Companion/Generic/EQS_FindCoverNearPlayer.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c7b6be5f989ea63aac50260d68dd846abb7a4a421a8d3fa81d193204c6514c68 +size 24886 diff --git a/EndlessVendetta/Content/__ExternalActors__/Levels/EnemyAITest/A/UU/P4XZ4FDZKD5IXIWK3JDDDK.uasset b/EndlessVendetta/Content/__ExternalActors__/Levels/EnemyAITest/A/UU/P4XZ4FDZKD5IXIWK3JDDDK.uasset new file mode 100644 index 00000000..c31f9729 --- /dev/null +++ b/EndlessVendetta/Content/__ExternalActors__/Levels/EnemyAITest/A/UU/P4XZ4FDZKD5IXIWK3JDDDK.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cf054aae033d323e2dc383293f32913ba2abc9f97ae89368159c2b9eb8c7e8bd +size 5073 diff --git a/EndlessVendetta/Content/__ExternalActors__/Levels/EnemyAITest/C/U2/RJOME4RGCN15IGVOBN2IPY.uasset b/EndlessVendetta/Content/__ExternalActors__/Levels/EnemyAITest/C/U2/RJOME4RGCN15IGVOBN2IPY.uasset new file mode 100644 index 00000000..c7e7eb8a --- /dev/null +++ b/EndlessVendetta/Content/__ExternalActors__/Levels/EnemyAITest/C/U2/RJOME4RGCN15IGVOBN2IPY.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fc0811871384ecf24f8ed7287814d09b40b34b84d18582e0a3dcd4273f9ac44d +size 5073 From af34f6a5870fbcdc63f820f2ecbdc221ad0a8448 Mon Sep 17 00:00:00 2001 From: PHILIP WHITE Date: Wed, 4 Oct 2023 02:30:47 +0100 Subject: [PATCH 5/5] Update Blackboard Key to Include Cover Location --- .../Content/AI/Companion/Generic/BB_GenericCompanion.uasset | 4 ++-- .../Levels/EnemyAITest/C/U2/RJOME4RGCN15IGVOBN2IPY.uasset | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) delete mode 100644 EndlessVendetta/Content/__ExternalActors__/Levels/EnemyAITest/C/U2/RJOME4RGCN15IGVOBN2IPY.uasset diff --git a/EndlessVendetta/Content/AI/Companion/Generic/BB_GenericCompanion.uasset b/EndlessVendetta/Content/AI/Companion/Generic/BB_GenericCompanion.uasset index 38798a46..13d036c4 100644 --- a/EndlessVendetta/Content/AI/Companion/Generic/BB_GenericCompanion.uasset +++ b/EndlessVendetta/Content/AI/Companion/Generic/BB_GenericCompanion.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:eaedcee2488826c0cbd4c69646da5a3f0b12d6815971805e9ecfbbdf4bc1a2ce -size 2258 +oid sha256:20197ccd89d5871cd395eac1941f9d29344e76e457d5ebd1200fd271f2ced360 +size 2627 diff --git a/EndlessVendetta/Content/__ExternalActors__/Levels/EnemyAITest/C/U2/RJOME4RGCN15IGVOBN2IPY.uasset b/EndlessVendetta/Content/__ExternalActors__/Levels/EnemyAITest/C/U2/RJOME4RGCN15IGVOBN2IPY.uasset deleted file mode 100644 index c7e7eb8a..00000000 --- a/EndlessVendetta/Content/__ExternalActors__/Levels/EnemyAITest/C/U2/RJOME4RGCN15IGVOBN2IPY.uasset +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:fc0811871384ecf24f8ed7287814d09b40b34b84d18582e0a3dcd4273f9ac44d -size 5073