diff --git a/EndlessVendetta/Content/AI/Enemy/Basic/BB_BasicEnemy.uasset b/EndlessVendetta/Content/AI/Enemy/Basic/BB_BasicEnemy.uasset index f631ee69..52c3d994 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:7e12facb03e605fcf3b7459c80c0ce5bd857df9f837d92a0b1f802dcf251ceff -size 2586 +oid sha256:0c439461f7778a2156b0c90fe965cd8bb56c84703110c655e5682b15da9ba2b7 +size 2952 diff --git a/EndlessVendetta/Content/AI/Enemy/Basic/BT_BasicEnemy.uasset b/EndlessVendetta/Content/AI/Enemy/Basic/BT_BasicEnemy.uasset index 2d4c633a..ced1ec89 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:f48b1e9b530fcb9a22eda28d4347ef5562fc9eaf7562f1d206c36b1ae0714889 -size 10205 +oid sha256:a6d42687973696b95d580795273e6993dd6eba1d2e5d513e21bf0d876a05c6e1 +size 9634 diff --git a/EndlessVendetta/Content/AI/Enemy/Basic/EQSB_Player.uasset b/EndlessVendetta/Content/AI/Enemy/Basic/EQSB_Player.uasset new file mode 100644 index 00000000..a1e8f59b --- /dev/null +++ b/EndlessVendetta/Content/AI/Enemy/Basic/EQSB_Player.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4da78b93d151ff916a8b62f09f88ce28b8efeb76a9d1d468a6e56f95d50a711d +size 17987 diff --git a/EndlessVendetta/Content/AI/Enemy/Basic/EQS_FindCover.uasset b/EndlessVendetta/Content/AI/Enemy/Basic/EQS_FindCover.uasset new file mode 100644 index 00000000..6e74a14b --- /dev/null +++ b/EndlessVendetta/Content/AI/Enemy/Basic/EQS_FindCover.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7fcaaf5f822a38ea450d63d75ae96d5207fd7b0d37e0c06edc04938dc3d19e48 +size 11056 diff --git a/EndlessVendetta/Content/AI/Enemy/Basic/EQS_Test.uasset b/EndlessVendetta/Content/AI/Enemy/Basic/EQS_Test.uasset new file mode 100644 index 00000000..eb8c4663 --- /dev/null +++ b/EndlessVendetta/Content/AI/Enemy/Basic/EQS_Test.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5f5b2ddf1641fad4bf9b75104089070dd382ab3b630619aa5cbb0fb19e215f22 +size 22729 diff --git a/EndlessVendetta/Content/FirstPerson/Maps/FirstPersonMap.umap b/EndlessVendetta/Content/FirstPerson/Maps/FirstPersonMap.umap index 18ab88e2..54eb07cc 100644 --- a/EndlessVendetta/Content/FirstPerson/Maps/FirstPersonMap.umap +++ b/EndlessVendetta/Content/FirstPerson/Maps/FirstPersonMap.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:50dc7643805f79735dcfd5446b36ff8ddea8adeda4b88438744192186c26f707 -size 19238 +oid sha256:89c980519d00e643fc39c075bf791f256c5cbedde3f1714c9b8dc549b66f747d +size 19936 diff --git a/EndlessVendetta/Content/__ExternalActors__/FirstPerson/Maps/FirstPersonMap/A/OW/M2M9BG6AWDJW3UNODUVGA2.uasset b/EndlessVendetta/Content/__ExternalActors__/FirstPerson/Maps/FirstPersonMap/A/OW/M2M9BG6AWDJW3UNODUVGA2.uasset index f061064d..d2ed851f 100644 --- a/EndlessVendetta/Content/__ExternalActors__/FirstPerson/Maps/FirstPersonMap/A/OW/M2M9BG6AWDJW3UNODUVGA2.uasset +++ b/EndlessVendetta/Content/__ExternalActors__/FirstPerson/Maps/FirstPersonMap/A/OW/M2M9BG6AWDJW3UNODUVGA2.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1988331cb675ef5854b9e0bf00b72da4746c2034323a0749b398193134f3c9d3 +oid sha256:e389d4fdd420c3db3068711fe04fd3fa8d65bdb13895ef085fc9deb499078797 size 5288 diff --git a/EndlessVendetta/Platforms/HoloLens/Config/HoloLensEngine.ini b/EndlessVendetta/Platforms/HoloLens/Config/HoloLensEngine.ini new file mode 100644 index 00000000..d5ebb91b --- /dev/null +++ b/EndlessVendetta/Platforms/HoloLens/Config/HoloLensEngine.ini @@ -0,0 +1,32 @@ + + +[/Script/HoloLensPlatformEditor.HoloLensTargetSettings] +bBuildForEmulation=False +bBuildForDevice=True +bUseNameForLogo=True +bBuildForRetailWindowsStore=False +bAutoIncrementVersion=False +bShouldCreateAppInstaller=False +AppInstallerInstallationURL= +HoursBetweenUpdateChecks=0 +bEnablePIXProfiling=False +TileBackgroundColor=(B=64,G=0,R=0,A=255) +SplashScreenBackgroundColor=(B=64,G=0,R=0,A=255) ++PerCultureResources=(CultureId="",Strings=(PackageDisplayName="",PublisherDisplayName="",PackageDescription="",ApplicationDisplayName="",ApplicationDescription=""),Images=()) +TargetDeviceFamily=Windows.Holographic +MinimumPlatformVersion= +MaximumPlatformVersionTested=10.0.18362.0 +MaxTrianglesPerCubicMeter=500.000000 +SpatialMeshingVolumeSize=20.000000 +CompilerVersion=Default +Windows10SDKVersion=10.0.18362.0 ++CapabilityList=internetClientServer ++CapabilityList=privateNetworkClientServer ++Uap2CapabilityList=spatialPerception +bSetDefaultCapabilities=False +SpatializationPlugin= +SourceDataOverridePlugin= +ReverbPlugin= +OcclusionPlugin= +SoundCueCookQualityIndex=-1 + diff --git a/EndlessVendetta/Source/EndlessVendetta/AI/AI_EnemyController.cpp b/EndlessVendetta/Source/EndlessVendetta/AI/AI_EnemyController.cpp new file mode 100644 index 00000000..eca94318 --- /dev/null +++ b/EndlessVendetta/Source/EndlessVendetta/AI/AI_EnemyController.cpp @@ -0,0 +1,83 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "AI_EnemyController.h" + +#include "EnemyCharacter.h" +#include "BehaviorTree/BlackboardComponent.h" +#include "Perception/AIPerceptionComponent.h" +#include "Perception/AISenseConfig_Sight.h" + + +// Sets default values +AAI_EnemyController::AAI_EnemyController(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; + + SetupPerceptionSystem(); +} + +// Called when the game starts or when spawned +void AAI_EnemyController::BeginPlay() +{ + Super::BeginPlay(); +} + +void AAI_EnemyController::OnPossess(APawn* InPawn) +{ + Super::OnPossess(InPawn); + if (const AEnemyCharacter* EnemyCharacter = Cast(InPawn)) + { + if (UBehaviorTree* const BehaviorTree = EnemyCharacter->GetBehaviorTree()) + { + UBlackboardComponent* TempBlackboardPtr; + UseBlackboard(BehaviorTree->BlackboardAsset, TempBlackboardPtr); + Blackboard = TempBlackboardPtr; + RunBehaviorTree(BehaviorTree); + } + } +} + +// Called every frame +void AAI_EnemyController::Tick(float DeltaTime) +{ + Super::Tick(DeltaTime); +} + +void AAI_EnemyController::SetupPerceptionSystem() +{ + SightConfig = CreateDefaultSubobject(TEXT("Sight Config")); + if (IsValid(SightConfig)) + { + SetPerceptionComponent(*CreateDefaultSubobject(TEXT("Perception Component"))); + SightConfig->SightRadius = 1000.0f; + SightConfig->LoseSightRadius = 1100.0f; + SightConfig->PeripheralVisionAngleDegrees = 90.0f; + SightConfig->SetMaxAge(5.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_EnemyController::OnTargetPerceptionUpdated); + GetPerceptionComponent()->ConfigureSense(*SightConfig); + } +} + +void AAI_EnemyController::OnTargetPerceptionUpdated(AActor* Actor, FAIStimulus const Stimulus) +{ + if (AEnemyCharacter* const EnemyCharacter = Cast(Actor)) + { + if (Stimulus.WasSuccessfullySensed()) + { + GetBlackboardComponent()->SetValueAsObject("TargetActor", Actor); + GetBlackboardComponent()->SetValueAsVector("TargetLocation", Stimulus.StimulusLocation); + } + else + { + GetBlackboardComponent()->ClearValue("TargetActor"); + GetBlackboardComponent()->ClearValue("TargetLocation"); + } + } +} diff --git a/EndlessVendetta/Source/EndlessVendetta/AI/AI_EnemyController.h b/EndlessVendetta/Source/EndlessVendetta/AI/AI_EnemyController.h new file mode 100644 index 00000000..786bb0c3 --- /dev/null +++ b/EndlessVendetta/Source/EndlessVendetta/AI/AI_EnemyController.h @@ -0,0 +1,35 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "AIController.h" +#include "Perception/AIPerceptionTypes.h" +#include "AI_EnemyController.generated.h" + +UCLASS() +class ENDLESSVENDETTA_API AAI_EnemyController : public AAIController +{ + GENERATED_BODY() + +public: + // Sets default values for this actor's properties + explicit AAI_EnemyController(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/BTTask_FindCover.cpp b/EndlessVendetta/Source/EndlessVendetta/AI/BTTask_FindCover.cpp new file mode 100644 index 00000000..af60b35c --- /dev/null +++ b/EndlessVendetta/Source/EndlessVendetta/AI/BTTask_FindCover.cpp @@ -0,0 +1,14 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "BTTask_FindCover.h" + +UBTTask_FindCover::UBTTask_FindCover(FObjectInitializer const& ObjectInitializer) +{ + NodeName = TEXT("Find Vaild Cover"); +} + +EBTNodeResult::Type UBTTask_FindCover::ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) +{ + return EBTNodeResult::Failed; +} diff --git a/EndlessVendetta/Source/EndlessVendetta/AI/BTTask_FindCover.h b/EndlessVendetta/Source/EndlessVendetta/AI/BTTask_FindCover.h new file mode 100644 index 00000000..8c1fa208 --- /dev/null +++ b/EndlessVendetta/Source/EndlessVendetta/AI/BTTask_FindCover.h @@ -0,0 +1,23 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "BehaviorTree/Tasks/BTTask_BlackboardBase.h" +#include "BTTask_FindCover.generated.h" + +/** + * + */ +UCLASS() +class ENDLESSVENDETTA_API UBTTask_FindCover : public UBTTask_BlackboardBase +{ + GENERATED_BODY() +public: + explicit UBTTask_FindCover(FObjectInitializer const& ObjectInitializer); + virtual EBTNodeResult::Type ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) override; + +private: + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "AI", meta = (AllowPrivateAccess = "true")) + float SearchRadius = 1000.f; +}; diff --git a/EndlessVendetta/Source/EndlessVendetta/AI/EnemyCharacter.cpp b/EndlessVendetta/Source/EndlessVendetta/AI/EnemyCharacter.cpp index 57a5285f..14827c11 100644 --- a/EndlessVendetta/Source/EndlessVendetta/AI/EnemyCharacter.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/AI/EnemyCharacter.cpp @@ -3,12 +3,17 @@ #include "EnemyCharacter.h" +#include "Perception/AIPerceptionStimuliSourceComponent.h" +#include "Perception/AISense_Sight.h" + +class UAISense_Sight; // Sets default values AEnemyCharacter::AEnemyCharacter() { // 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; + SetupStimuliSourceComponent(); } // Called when the game starts or when spawned @@ -30,3 +35,18 @@ void AEnemyCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComp Super::SetupPlayerInputComponent(PlayerInputComponent); } +UBehaviorTree* AEnemyCharacter::GetBehaviorTree() const +{ + return BehaviorTree; +} + +void AEnemyCharacter::SetupStimuliSourceComponent() +{ + StimuliSourceComponent = CreateDefaultSubobject(TEXT("Stimuli Source Component")); + if (IsValid(StimuliSourceComponent)) + { + StimuliSourceComponent->RegisterForSense(TSubclassOf()); + StimuliSourceComponent->RegisterWithPerceptionSystem(); + } +} + diff --git a/EndlessVendetta/Source/EndlessVendetta/AI/EnemyCharacter.h b/EndlessVendetta/Source/EndlessVendetta/AI/EnemyCharacter.h index 74e529e5..23e7e3be 100644 --- a/EndlessVendetta/Source/EndlessVendetta/AI/EnemyCharacter.h +++ b/EndlessVendetta/Source/EndlessVendetta/AI/EnemyCharacter.h @@ -3,6 +3,7 @@ #pragma once #include "CoreMinimal.h" +#include "BehaviorTree/BehaviorTree.h" #include "GameFramework/Character.h" #include "EnemyCharacter.generated.h" @@ -19,10 +20,19 @@ 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(); };