Add EnemyCharacter class
This commit is contained in:
parent
1ecb6e005a
commit
33e0d24d34
|
@ -0,0 +1,40 @@
|
||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
#include "EnemyCharacter.h"
|
||||||
|
#include "GameFramework/CharacterMovementComponent.h"
|
||||||
|
#include "EnemyAIController.h"
|
||||||
|
|
||||||
|
AEnemyCharacter::AEnemyCharacter()
|
||||||
|
{
|
||||||
|
PerceptionComponent = CreateDefaultSubobject<UAIPerceptionComponent>(TEXT("Perception Component"));
|
||||||
|
|
||||||
|
SightConfig = CreateDefaultSubobject<UAISenseConfig_Sight>(TEXT("Sight Configuration"));
|
||||||
|
SightConfig->SightRadius = 700.0f;
|
||||||
|
SightConfig->LoseSightRadius = 850.0f;
|
||||||
|
SightConfig->PeripheralVisionAngleDegrees = 90.0f;
|
||||||
|
SightConfig->SetMaxAge(5.0f);
|
||||||
|
SightConfig->DetectionByAffiliation.bDetectEnemies = true;
|
||||||
|
SightConfig->DetectionByAffiliation.bDetectNeutrals = true;
|
||||||
|
|
||||||
|
PerceptionComponent->SetDominantSense(SightConfig->GetSenseImplementation());
|
||||||
|
PerceptionComponent->ConfigureSense(*SightConfig);
|
||||||
|
|
||||||
|
GetHealthComponent()->SetMaxHealth(100.0f);
|
||||||
|
|
||||||
|
this->Tags.Add(FName("Enemy"));
|
||||||
|
}
|
||||||
|
|
||||||
|
UBehaviorTree* AEnemyCharacter::GetBehaviourTree()
|
||||||
|
{
|
||||||
|
return BehaviourTree;
|
||||||
|
}
|
||||||
|
|
||||||
|
UAIPerceptionComponent* AEnemyCharacter::GetPerceptionComponent()
|
||||||
|
{
|
||||||
|
return PerceptionComponent;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AEnemyCharacter::BeginPlay()
|
||||||
|
{
|
||||||
|
Super::BeginPlay();
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "NakatomiCharacter.h"
|
||||||
|
#include "BehaviorTree/BehaviorTreeComponent.h"
|
||||||
|
#include "Perception/AIPerceptionComponent.h"
|
||||||
|
#include <Perception/AISenseConfig_Sight.h>
|
||||||
|
#include "EnemyCharacter.generated.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
UCLASS()
|
||||||
|
class NAKATOMI_API AEnemyCharacter : public ANakatomiCharacter
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
private:
|
||||||
|
UAIPerceptionComponent* PerceptionComponent;
|
||||||
|
|
||||||
|
UAISenseConfig_Sight* SightConfig;
|
||||||
|
|
||||||
|
UPROPERTY(EditDefaultsOnly, Meta = (AllowPrivateAccess = "true"))
|
||||||
|
UBehaviorTree* BehaviourTree;
|
||||||
|
|
||||||
|
public:
|
||||||
|
AEnemyCharacter();
|
||||||
|
|
||||||
|
UBehaviorTree* GetBehaviourTree();
|
||||||
|
|
||||||
|
UAIPerceptionComponent* GetPerceptionComponent();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void BeginPlay() override;
|
||||||
|
};
|
Loading…
Reference in New Issue