Task node not ticking

Hey guys, I trying again the get an answer for this problem that has been bugging for 2 weeks now. have a behavior tree connected to a minion. The minion is suppose to attack any minion from the other team. My problem is that after a single attack it goes onto an infinite cooldown. I think my problem is that my cooldown task never calls TickTask() even though “InProgress” is used. Could anyone help, this one is really annoying me.

Cooldown.cpp

#include "ProjetDEC.h"
#include "BehaviorTree/BehaviorTree.h"
#include "BehaviorTree/BehaviorTreeComponent.h"
#include "BehaviorTree/BlackboardComponent.h"
#include "BehaviorTree/BlackBoard/BlackboardKeyAllTypes.h"
#include "Minion.h"
#include "MinionAI.h"
#include "BTTask_Cooldown.h"

EBTNodeResult::Type UBTTask_Cooldown::ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) {
	//getting the controller
	TaskOwnerComp = &OwnerComp;
	AMinionAI *MinionPC = Cast<AMinionAI>(OwnerComp.GetAIOwner());
	//getting the minion controlled by the MinionAI controller
	AMinion *ThisMinion = Cast<AMinion>(MinionPC->GetPawn());

	WaitTime = ThisMinion->GetAttackDelay();

	return EBTNodeResult::InProgress;
}

void UBTTask_Cooldown::TickTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, float DeltaSeconds)
{
	WaitTime -= DeltaSeconds;

   if (WaitTime <= 0.0f)
	{
		// continue execution from this node
		FinishLatentTask(OwnerComp, EBTNodeResult::Succeeded);
	}
}

Cooldown.h

#pragma once

#include "BehaviorTree/Tasks/BTTask_BlackboardBase.h"
#include "BTTask_Cooldown.generated.h"

UCLASS()
class PROJETDEC_API UBTTask_Cooldown : public UBTTask_BlackboardBase
{
	GENERATED_BODY()
	
public:
	virtual EBTNodeResult::Type ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) override;

protected:
	virtual void TickTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, float DeltaSeconds) override;
	
private:
	UBehaviorTreeComponent* TaskOwnerComp;
	float WaitTime;
};

Thanks again guys!

Inside ExecuteTask method:

bNotifyTick = 1;

should be called.

3 Likes

Thanks!!!