Add reworked Worker Enemy AI #3
							
								
								
									
										
											BIN
										
									
								
								Content/TestPatrolRoute.uasset
									 (Stored with Git LFS)
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Content/TestPatrolRoute.uasset
									 (Stored with Git LFS)
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										28
									
								
								Source/Nakatomi/Tasks/BTTMoveAlongPatrolRoute.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								Source/Nakatomi/Tasks/BTTMoveAlongPatrolRoute.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,28 @@
 | 
			
		||||
// Fill out your copyright notice in the Description page of Project Settings.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#include "../Tasks/BTTMoveAlongPatrolRoute.h"
 | 
			
		||||
 | 
			
		||||
#include "navigationSystem.h"
 | 
			
		||||
#include "BehaviorTree/BlackboardComponent.h"
 | 
			
		||||
#include "Nakatomi/EnemyAIController.h"
 | 
			
		||||
#include "Nakatomi/NakatomiCMC.h"
 | 
			
		||||
 | 
			
		||||
EBTNodeResult::Type UBTTMoveAlongPatrolRoute::ExecuteTask(UBehaviorTreeComponent& owner, uint8* memory)
 | 
			
		||||
{
 | 
			
		||||
	AEnemyAIController* enemyController = Cast<AEnemyAIController>(owner.GetAIOwner());
 | 
			
		||||
	AEnemyCharacter* enemyPawn = Cast<AEnemyCharacter>(enemyController->GetPawn());
 | 
			
		||||
 | 
			
		||||
	if (enemyPawn->CurrentPatrolRoute)
 | 
			
		||||
	{
 | 
			
		||||
		FVector location = enemyPawn->CurrentPatrolRoute->GetSplinePointAtWorld();
 | 
			
		||||
		UBlackboardComponent* blackboardComponent = owner.GetBlackboardComponent();
 | 
			
		||||
		blackboardComponent->SetValueAsVector(PatrolLocationKey.SelectedKeyName, location);
 | 
			
		||||
 | 
			
		||||
		enemyPawn->CurrentPatrolRoute->IncrementPatrolRoute();
 | 
			
		||||
		
 | 
			
		||||
		return EBTNodeResult::Succeeded;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return EBTNodeResult::Failed;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										24
									
								
								Source/Nakatomi/Tasks/BTTMoveAlongPatrolRoute.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								Source/Nakatomi/Tasks/BTTMoveAlongPatrolRoute.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,24 @@
 | 
			
		||||
// Fill out your copyright notice in the Description page of Project Settings.
 | 
			
		||||
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include "CoreMinimal.h"
 | 
			
		||||
#include "BehaviorTree/BTTaskNode.h"
 | 
			
		||||
#include "BTTMoveAlongPatrolRoute.generated.h"
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 
 | 
			
		||||
 */
 | 
			
		||||
UCLASS()
 | 
			
		||||
class NAKATOMI_API UBTTMoveAlongPatrolRoute : public UBTTaskNode
 | 
			
		||||
{
 | 
			
		||||
	GENERATED_BODY()
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
	UPROPERTY(EditAnywhere, Category = "Options",
 | 
			
		||||
	Meta = (AllowPrivateAccess = "true", DisplayName = "Patrol Location Key"))
 | 
			
		||||
	FBlackboardKeySelector PatrolLocationKey;
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
	virtual EBTNodeResult::Type ExecuteTask(UBehaviorTreeComponent& owner, uint8* memory) override;
 | 
			
		||||
};
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user