Latent method resumes in an infinite loop

I was working on a blueprint driven conversation system and need a node that would wait for the player to pick a conversation option before resuming the blueprint execution. When I added it I noticed that when the blueprint was resumed by player input it would immediately execute the node again and start waiting for player input once more. The only difference between this and other latent functions I’ve seen was that it was not static and that it had no parameters other than FLatentActionInfo.

Here is a reduced example that seems to have the same behavior:

/**
 * A test for two latent methods.
 */
UCLASS()
class LATENTTEST_API ALatentTestGameMode : public AGameMode
{
	GENERATED_BODY()
	
public:
	UFUNCTION(BlueprintCallable, meta=(Latent, LatentInfo="LatentInfo"), Category="Test")
	void LatentFunctionNoArgs(FLatentActionInfo LatentInfo);

	UFUNCTION(BlueprintCallable, meta=(Latent, LatentInfo="LatentInfo"), Category="Test")
	void LatentFunctionWithArgs(float Dummy, FLatentActionInfo LatentInfo);
};

The implementation does nothing more than call Delay.

void ALatentTestGameMode::LatentFunctionNoArgs(FLatentActionInfo LatentInfo)
{
	UKismetSystemLibrary::Delay(this, 1.0f, LatentInfo);
}

void ALatentTestGameMode::LatentFunctionWithArgs(float Dummy, FLatentActionInfo LatentInfo)
{
	UKismetSystemLibrary::Delay(this, 1.0f, LatentInfo);
}

Next is an instance of a game mode blueprint created with ALatentTestGameMode as its base. Only the BeginPlay event is wired up.

This blueprint can now be used as the override game mode in a newly created level.

When the exec is wired up to “Latent Function No Args” as in the screenshot, the breakpoint is never hit and the text is never printed. Putting the breakpoint on the latent node itself hits the breakpoint every one second.

On the other hand, when the exec is wired up to “Latent Function with Args” the blueprint runs as expected with the breakpoint being hit and the string printed after one second.

Hey okoz-

Thank you for reporting this. I have entered a bug for this issue (UE-22342) for further investigation.

Cheers

You can use this as a simple fix:

UFUNCTION(BlueprintCallable, meta=(Latent, WorldContext="WorldContextObject", LatentInfo="LatentInfo"), Category="Test")
	void LatentFunctionNoArgs(UObject* WorldContextObject, FLatentActionInfo LatentInfo);

just added WorldContextObject, which gets passed to delay.

Hey . I tested this issue in 4.14. It’s still present. It’s not a huge issue if you know about it and how to get around it but I do think that this bug is something that should be addressed.

Hey MJLaukala-

The reported issue is still open and can be viewed here: Unreal Engine Issues and Bug Tracker (UE-22342) . You can vote on and track the report’s status as it is reviewd by our development staff. Please be aware that this issue may not be prioritized or fixed soon.

thank you so much for this!

Hi , is there any info on why that issue was marked “Won’t Fix”? It still exists in 4.25 and the 4.26 previews - any custom latent action taking FLatentActionInfo as the first parameter will be called infinitely.