Merge branch 'Enemy-AI' into dev
# Conflicts: # EndlessVendetta/Content/Gadgets/ReconGadgets/VisionLink/VisionLinkViewPortBG.uasset # EndlessVendetta/Content/Gadgets/ReconGadgets/VisionLink/WatchFaceBGImage.uasset
This commit is contained in:
commit
8fc80f9b31
BIN
EndlessVendetta/Content/AI/Companion/Generic/BB_GenericCompanion.uasset
(Stored with Git LFS)
Normal file
BIN
EndlessVendetta/Content/AI/Companion/Generic/BB_GenericCompanion.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
EndlessVendetta/Content/AI/Companion/Generic/BT_GenericCompanion.uasset
(Stored with Git LFS)
Normal file
BIN
EndlessVendetta/Content/AI/Companion/Generic/BT_GenericCompanion.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
EndlessVendetta/Content/AI/Companion/Generic/CompanionCharacter.uasset
(Stored with Git LFS)
Normal file
BIN
EndlessVendetta/Content/AI/Companion/Generic/CompanionCharacter.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
EndlessVendetta/Content/AI/Companion/Generic/EQS_FindCoverNearPlayer.uasset
(Stored with Git LFS)
Normal file
BIN
EndlessVendetta/Content/AI/Companion/Generic/EQS_FindCoverNearPlayer.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
EndlessVendetta/Content/AI/EQSB_Enemy.uasset
(Stored with Git LFS)
Normal file
BIN
EndlessVendetta/Content/AI/EQSB_Enemy.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
EndlessVendetta/Content/AI/EQSB_Player.uasset
(Stored with Git LFS)
Normal file
BIN
EndlessVendetta/Content/AI/EQSB_Player.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
EndlessVendetta/Content/AI/EQS_Test.uasset
(Stored with Git LFS)
Normal file
BIN
EndlessVendetta/Content/AI/EQS_Test.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
EndlessVendetta/Content/AI/Enemy/Basic/BB_BasicEnemy.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/AI/Enemy/Basic/BB_BasicEnemy.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
EndlessVendetta/Content/AI/Enemy/Basic/BP_BasicEnemyCharacter.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/AI/Enemy/Basic/BP_BasicEnemyCharacter.uasset
(Stored with Git LFS)
Binary file not shown.
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/AI/Enemy/Basic/EQSB_Player.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/AI/Enemy/Basic/EQSB_Player.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
EndlessVendetta/Content/AI/Enemy/Basic/EQS_EnemyFindCover.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/AI/Enemy/Basic/EQS_EnemyFindCover.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
EndlessVendetta/Content/AI/Enemy/Basic/EQS_Test.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/AI/Enemy/Basic/EQS_Test.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
EndlessVendetta/Content/__ExternalActors__/Levels/EnemyAITest/A/UU/P4XZ4FDZKD5IXIWK3JDDDK.uasset
(Stored with Git LFS)
Normal file
BIN
EndlessVendetta/Content/__ExternalActors__/Levels/EnemyAITest/A/UU/P4XZ4FDZKD5IXIWK3JDDDK.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
EndlessVendetta/Content/__ExternalActors__/Levels/EnemyAITest/B/AZ/GX8EY01G00J28SE17R0FJV.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/__ExternalActors__/Levels/EnemyAITest/B/AZ/GX8EY01G00J28SE17R0FJV.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
EndlessVendetta/Content/__ExternalActors__/Levels/EnemyAITest/E/PJ/BY6E8JXZSRNMAW3DFHRHRJ.uasset
(Stored with Git LFS)
Normal file
BIN
EndlessVendetta/Content/__ExternalActors__/Levels/EnemyAITest/E/PJ/BY6E8JXZSRNMAW3DFHRHRJ.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -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<ACompanionCharacter>(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<UAISenseConfig_Sight>(TEXT("Sight Config"));
|
||||
if (IsValid(SightConfig))
|
||||
{
|
||||
SetPerceptionComponent(*CreateDefaultSubobject<UAIPerceptionComponent>(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<AEndlessVendettaCharacter>(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);
|
||||
// }
|
||||
}
|
||||
}
|
@ -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);
|
||||
|
||||
};
|
@ -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;
|
||||
|
||||
AAIController::SetGenericTeamId(FGenericTeamId(1));
|
||||
SetupPerceptionSystem();
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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<UAIPerceptionStimuliSourceComponent>(TEXT("Stimuli Source Component"));
|
||||
if (IsValid(StimuliSourceComponent))
|
||||
{
|
||||
StimuliSourceComponent->RegisterForSense(TSubclassOf<UAISense_Sight>());
|
||||
StimuliSourceComponent->RegisterWithPerceptionSystem();
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
};
|
Loading…
Reference in New Issue
Block a user