Hi, I have been messing around with UBlueprintAsyncActionBase and FPendingLatentAction to control the flow execution in BP. Essentially I the node triggers an action and the execution should continue once the action is done.
I use a delegate to know when the action has ended and got it working with UBlueprintAsyncActionBase. The problem is that the node is available from any class, I wan it to be used like a regular function, ONLY on this class.
On the other hand with FPendingLatentAction I get the class only behavior just by adding the latent action in the class function. But I cannot seem able to bind the end with the delegate. I need it to work with the delegate as I need it to return the action state.
FPendingLatentAction .h
UFUNCTION(BlueprintCallable, Category = "BP", meta = (Latent, LatentInfo = "LatentInfo", HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject"))
virtual void GetRequest(UObject* WorldContextObject, struct FLatentActionInfo LatentInfo);
FPendingLatentAction .cpp
void UUnitBehavior::GetRequest(UObject* WorldContextObject, FLatentActionInfo LatentInfo)
{
// Prepare latent action
if (UWorld* World = GEngine->GetWorldFromContextObjectChecked(WorldContextObject) )
{
FLatentActionManager& LatentActionManager = World->GetLatentActionManager();
if (LatentActionManager.FindExistingAction<FDelayAction>(LatentInfo.CallbackTarget, LatentInfo.UUID) == NULL)
{
LatentActionManager.AddNewAction(LatentInfo.CallbackTarget, LatentInfo.UUID, new FDelayAction( 5.0f, LatentInfo));
}
}
}