Compare commits
2 Commits
03d5b80a0b
...
b381da2744
Author | SHA1 | Date |
---|---|---|
baz | b381da2744 | |
baz | dcd292cb48 |
|
@ -0,0 +1,34 @@
|
||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
|
||||||
|
#include "PatrolRoute.h"
|
||||||
|
|
||||||
|
// Sets default values
|
||||||
|
APatrolRoute::APatrolRoute()
|
||||||
|
{
|
||||||
|
PrimaryActorTick.bCanEverTick = false;
|
||||||
|
|
||||||
|
Spline = CreateDefaultSubobject<USplineComponent>(TEXT("Spline"));
|
||||||
|
Spline->SetupAttachment(RootComponent);
|
||||||
|
}
|
||||||
|
|
||||||
|
void APatrolRoute::IncrementPatrolRoute()
|
||||||
|
{
|
||||||
|
if (PatrolIndex == Spline->GetNumberOfSplinePoints() - 1)
|
||||||
|
{
|
||||||
|
Direction = -1;
|
||||||
|
}
|
||||||
|
else if (PatrolIndex == 0)
|
||||||
|
{
|
||||||
|
Direction = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
PatrolIndex += Direction;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
FVector APatrolRoute::GetSplinePointAtWorld(int pointIndex)
|
||||||
|
{
|
||||||
|
return Spline->GetLocationAtSplinePoint(pointIndex, ESplineCoordinateSpace::World);
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "Components/SplineComponent.h"
|
||||||
|
#include "GameFramework/Actor.h"
|
||||||
|
#include "PatrolRoute.generated.h"
|
||||||
|
|
||||||
|
UCLASS()
|
||||||
|
class NAKATOMI_API APatrolRoute : public AActor
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
UPROPERTY(BlueprintReadWrite)
|
||||||
|
USplineComponent* Spline;
|
||||||
|
|
||||||
|
private:
|
||||||
|
int PatrolIndex = 0;
|
||||||
|
|
||||||
|
int Direction;
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Sets default values for this actor's properties
|
||||||
|
APatrolRoute();
|
||||||
|
|
||||||
|
void IncrementPatrolRoute();
|
||||||
|
|
||||||
|
FVector GetSplinePointAtWorld(int pointIndex);
|
||||||
|
};
|
|
@ -9,6 +9,5 @@ EBTNodeResult::Type UBTTClearFocus::ExecuteTask(UBehaviorTreeComponent& owner, u
|
||||||
{
|
{
|
||||||
auto enemyController = Cast<AEnemyAIController>(owner.GetAIOwner());
|
auto enemyController = Cast<AEnemyAIController>(owner.GetAIOwner());
|
||||||
enemyController->ClearFocus(EAIFocusPriority::Default);
|
enemyController->ClearFocus(EAIFocusPriority::Default);
|
||||||
enemyController->SetFocus();
|
|
||||||
return EBTNodeResult::Succeeded;
|
return EBTNodeResult::Succeeded;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue