Compare commits
No commits in common. "9e81450656e85fafcba07430e78797eab2d227e4" and "a1832e352e3d209265825e08528d3aefdfa0e269" have entirely different histories.
9e81450656
...
a1832e352e
BIN
Content/Enemy/EQS/AttackTarget.uasset (Stored with Git LFS)
BIN
Content/Enemy/EQS/AttackTarget.uasset (Stored with Git LFS)
Binary file not shown.
BIN
Content/Enemy/EQS/EQSTestingPawn.uasset (Stored with Git LFS)
BIN
Content/Enemy/EQS/EQSTestingPawn.uasset (Stored with Git LFS)
Binary file not shown.
BIN
Content/Enemy/EQS/EQS_Strafe.uasset (Stored with Git LFS)
BIN
Content/Enemy/EQS/EQS_Strafe.uasset (Stored with Git LFS)
Binary file not shown.
BIN
Content/Enemy/Tasks/BTTMoveToIdealRange.uasset (Stored with Git LFS)
BIN
Content/Enemy/Tasks/BTTMoveToIdealRange.uasset (Stored with Git LFS)
Binary file not shown.
BIN
Content/Enemy/Worker/BB_Worker.uasset (Stored with Git LFS)
BIN
Content/Enemy/Worker/BB_Worker.uasset (Stored with Git LFS)
Binary file not shown.
BIN
Content/Enemy/Worker/BT_Worker.uasset (Stored with Git LFS)
BIN
Content/Enemy/Worker/BT_Worker.uasset (Stored with Git LFS)
Binary file not shown.
|
@ -1,29 +0,0 @@
|
||||||
// Fill out your copyright notice in the Description page of Project Settings.
|
|
||||||
|
|
||||||
|
|
||||||
#include "../Decorators/BTDIsWithinRange.h"
|
|
||||||
|
|
||||||
#include "AIController.h"
|
|
||||||
#include "navigationSystem.h"
|
|
||||||
#include "BehaviorTree/BlackboardComponent.h"
|
|
||||||
#include "Nakatomi/NakatomiCharacter.h"
|
|
||||||
|
|
||||||
bool UBTDIsWithinRange::CalculateRawConditionValue(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) const
|
|
||||||
{
|
|
||||||
UBlackboardComponent* BlackboardComponent = OwnerComp.GetBlackboardComponent();
|
|
||||||
float Dist = BlackboardComponent->GetValueAsFloat(DistanceKey.SelectedKeyName);
|
|
||||||
UObject* Target = BlackboardComponent->GetValueAsObject(TargetActorKey.SelectedKeyName);
|
|
||||||
auto TargetLocation = Cast<AActor>(Target)->GetActorLocation();
|
|
||||||
UNavigationSystemV1* NavigationSystem = FNavigationSystem::GetCurrent<UNavigationSystemV1>(GetWorld());
|
|
||||||
|
|
||||||
APawn* pawn = OwnerComp.GetAIOwner()->GetPawn();
|
|
||||||
|
|
||||||
if (pawn && NavigationSystem && TargetLocation != FVector::ZeroVector)
|
|
||||||
{
|
|
||||||
double Distance = -1.0;
|
|
||||||
NavigationSystem->GetPathLength(TargetLocation, pawn->GetTransform().GetLocation(), Distance);
|
|
||||||
return Distance <= Dist ? true : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
|
@ -1,31 +0,0 @@
|
||||||
// Fill out your copyright notice in the Description page of Project Settings.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "CoreMinimal.h"
|
|
||||||
#include "BehaviorTree/BTDecorator.h"
|
|
||||||
#include "BTDIsWithinRange.generated.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
UCLASS()
|
|
||||||
class NAKATOMI_API UBTDIsWithinRange : public UBTDecorator
|
|
||||||
{
|
|
||||||
GENERATED_BODY()
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, Category = "Options",
|
|
||||||
Meta = (AllowPrivateAccess = "true", DisplayName = "Target Actor Key"))
|
|
||||||
FBlackboardKeySelector TargetActorKey;
|
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, Category = "Options",
|
|
||||||
Meta = (AllowPrivateAccess = "true", DisplayName = "Distance Key"))
|
|
||||||
FBlackboardKeySelector DistanceKey;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual bool CalculateRawConditionValue(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) const override;
|
|
||||||
|
|
||||||
};
|
|
|
@ -12,5 +12,4 @@ enum class EPatrolMovementEnum : uint8
|
||||||
{
|
{
|
||||||
SLOWWALK UMETA(DisplayName = "Slow Walk"),
|
SLOWWALK UMETA(DisplayName = "Slow Walk"),
|
||||||
WALK UMETA(DisplayName = "Walk"),
|
WALK UMETA(DisplayName = "Walk"),
|
||||||
SPRINT UMETA(DisplayName = "Sprint"),
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -64,9 +64,6 @@ void AEnemyAIController::OnPossess(APawn* InPawn)
|
||||||
|
|
||||||
Blackboard->SetValueAsEnum("State", static_cast<uint8>(EAIState::PASSIVE));
|
Blackboard->SetValueAsEnum("State", static_cast<uint8>(EAIState::PASSIVE));
|
||||||
|
|
||||||
Blackboard->SetValueAsFloat("AttackRadius", enemy->AttackRadius);
|
|
||||||
Blackboard->SetValueAsFloat("DefendRadius", enemy->DefendRadius);
|
|
||||||
|
|
||||||
//ensure(enemy->GetMovementComponent()->UseAccelerationForPathFollowing());
|
//ensure(enemy->GetMovementComponent()->UseAccelerationForPathFollowing());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,24 +149,9 @@ void AEnemyAIController::OnPerceptionUpdated(const TArray<AActor*>& actors)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
FAISenseID SightID;
|
FAISenseID SightID = SightConfig->GetSenseID();
|
||||||
FAISenseID HearingID;
|
FAISenseID HearingID = HearingConfig->GetSenseID();
|
||||||
FAISenseID DamageID;
|
FAISenseID DamageID = DamageConfig->GetSenseID();
|
||||||
|
|
||||||
if (SightConfig)
|
|
||||||
{
|
|
||||||
SightID = SightConfig->GetSenseID();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (HearingConfig)
|
|
||||||
{
|
|
||||||
HearingID = HearingConfig->GetSenseID();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (DamageConfig)
|
|
||||||
{
|
|
||||||
DamageID = DamageConfig->GetSenseID();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (stimulus.Type == SightID)
|
if (stimulus.Type == SightID)
|
||||||
{
|
{
|
||||||
|
@ -247,11 +229,6 @@ void AEnemyAIController::SetStateAsAttacking(AActor* target)
|
||||||
SetState(EAIState::ATTACKING);
|
SetState(EAIState::ATTACKING);
|
||||||
}
|
}
|
||||||
|
|
||||||
AActor* AEnemyAIController::GetTargetActor()
|
|
||||||
{
|
|
||||||
return Cast<AActor>(Blackboard->GetValueAsObject("TargetActor"));
|
|
||||||
}
|
|
||||||
|
|
||||||
void AEnemyAIController::SensedSight(AActor* actor, FAIStimulus& stimulus)
|
void AEnemyAIController::SensedSight(AActor* actor, FAIStimulus& stimulus)
|
||||||
{
|
{
|
||||||
EAIState CurrentState = static_cast<EAIState>(Blackboard->GetValueAsEnum("State"));
|
EAIState CurrentState = static_cast<EAIState>(Blackboard->GetValueAsEnum("State"));
|
||||||
|
|
|
@ -76,9 +76,6 @@ public:
|
||||||
UFUNCTION()
|
UFUNCTION()
|
||||||
void SetStateAsAttacking(AActor* target);
|
void SetStateAsAttacking(AActor* target);
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable)
|
|
||||||
AActor* GetTargetActor();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void SensedSight(AActor* actor, FAIStimulus& stimulus);
|
void SensedSight(AActor* actor, FAIStimulus& stimulus);
|
||||||
|
|
|
@ -22,12 +22,6 @@ public:
|
||||||
UPROPERTY(EditAnywhere, Meta = (AllowPrivateAccess = "true"))
|
UPROPERTY(EditAnywhere, Meta = (AllowPrivateAccess = "true"))
|
||||||
APatrolRoute* CurrentPatrolRoute;
|
APatrolRoute* CurrentPatrolRoute;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere)
|
|
||||||
float AttackRadius = 300.0;
|
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere)
|
|
||||||
float DefendRadius = 500.0f;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UPROPERTY(EditDefaultsOnly, Meta = (AllowPrivateAccess = "true"))
|
UPROPERTY(EditDefaultsOnly, Meta = (AllowPrivateAccess = "true"))
|
||||||
UBehaviorTree* BehaviourTree;
|
UBehaviorTree* BehaviourTree;
|
||||||
|
|
|
@ -21,9 +21,6 @@ EBTNodeResult::Type UBTTSetMovementSpeed::ExecuteTask(UBehaviorTreeComponent& ow
|
||||||
case EPatrolMovementEnum::WALK:
|
case EPatrolMovementEnum::WALK:
|
||||||
enemyPawn->GetCharacterMovementComponent()->SetMaxWalkSpeed(walkSpeed);
|
enemyPawn->GetCharacterMovementComponent()->SetMaxWalkSpeed(walkSpeed);
|
||||||
break;
|
break;
|
||||||
case EPatrolMovementEnum::SPRINT:
|
|
||||||
enemyPawn->GetCharacterMovementComponent()->SetMaxWalkSpeed(sprintSpeed);
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
enemyPawn->GetCharacterMovementComponent()->SetMaxWalkSpeedToDefault();
|
enemyPawn->GetCharacterMovementComponent()->SetMaxWalkSpeedToDefault();
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -26,8 +26,6 @@ private:
|
||||||
|
|
||||||
float walkSpeed = 500.0f;
|
float walkSpeed = 500.0f;
|
||||||
|
|
||||||
float sprintSpeed = 750.0f;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual EBTNodeResult::Type ExecuteTask(UBehaviorTreeComponent& owner, uint8* memory) override;
|
virtual EBTNodeResult::Type ExecuteTask(UBehaviorTreeComponent& owner, uint8* memory) override;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue