Skip to content

Programming Guide

Michael Adaixo edited this page Dec 28, 2023 · 14 revisions

FlowPilot Task Node

Each TaskNode will finish when its Tick() method returns anything different than EFPNodeREsult::InProgress. If you don't override FPTaskNode::Tick(), the task will automatically Succeed after entering. If you need to wait, you have to override this method, and return your own value. See FPTask_Delay or other for reference.

Virtual Methods

UFPNode

// UFPNode
virtual void Setup(FFlowContext* InContext);
//~UFPNode

This is called once at the start of FlowPilot execution, for all Tasks in the FlowPilot Asset.

UFPTaskNode

// UFPTaskNode
virtual bool Enter();
virtual EFPNodeResult Tick(float DeltaTime);
virtual void Exit();
virtual void Abort();
	
virtual bool HasChildNodes() const { return false; }
virtual void GetChildNodes(TArray<TObjectPtr<UFPTaskNode>>& OutChildNodes) PURE_VIRTUAL(,)
virtual uint32 GetNumChildNodes() const { return 0; }
//~UFPTaskNode

New FlowPilot Task Node Class

Example "Open Door" interation

UCLASS(DisplayName="Interaction | Open Door")
class MYGAME_API UFPTask_OpenDoor : public UFPTaskNode
{
	GENERATED_BODY()
	
public:
	UFPTask_OpenDoor();
	
	virtual void Setup(FFlowContext* InContext) override;
	virtual bool Enter() override;

protected:
	// First Actor Tag
	UPROPERTY(EditAnywhere, Category = "Flow Pilot")
	FFlowActorReference ActorReference;

private:

};

This Task doesn't tick and will return Success automatically after Enter() is called, on the next Tick frame.

Example Implementation:

bool UFPTask_OpenDoor::Enter()
{
	AActor* Actor = FindActor(ActorReference);
	if (!IsValid(Actor))
	{
		return false;
	}

	ASingleDoor* SingleDoor = Cast<ASingleDoor>(Actor);
	if(!IsValid(SingleDoor))
	{
		return false;
	}
	
	return SingleDoor->OpenDoor(GetFlowOwningActor());
}

New Blueprint based FlowPilot Class

To make a new FlowPilot Class in Blueprint.

  1. Create new Blueprint.
  2. Select FPTask_BlueprintBase or FPInstant_BlueprintBase

image

  1. Implement needed virtual methods with implementation details.

image

  1. Add need variables. For example, you'll want to add FFlowActorReferences so that you can tap into the FlowPilot System, of finding actors on scene, track and finding them via GameplayTags.

image

Example implemetation of Turning an Array of Lights On/Off image

  1. Setup and Profit

image

Clone this wiki locally