How does the FLatentActionInfo Linkage variable work?

So I’ve been digging into the latent action info struct recently, and so far I cant seem to understand how to use the Linkage variable. I’ve only seen other people just put zero and sometimes one for that but nobody seems to explain why, what happens if I put a random number?

I know its a resume point within the function to execute because thats what the comment for the variable says but I dont understand how it would keep track of that when we seem to just set the variable to any number really. I do understand what Unique ID and the execution function and callback target(the names for those explain it really) are used for with latent actions. I would appreciate any help with understanding this a little better :slight_smile:

FLatentActionInfo info;
info.CallbackTarget = this;
// This is just a generic name I thought of for this example
info.ExecutionFunction = TEXT("SpawnMap");
info.UUID = 0;
// Why this number?
info.Linkage = 0;

I’m afraid I’m going to turn you down. You can’t directly use the Linkage parameter.
Here are some things to do if you want to use it:

  1. Your function can only have one argument int32, if you have any other arguments, you should create another function and asign these argumants to class member

void YourFunction(YourArg1 Arg1, YourArg2 Arg2)
{
MemberArg1 = Arg1;
MemberArg2 = Arg2;
YourLinkageFunction(0); // Can use Linkage function
}

  1. Your Lingage function should use switch case as below

void YourLinkageFunction(int32 Linkage)
{
switch(Linkage)
{
case 0:
case 1:
FLatentActionInfo LatentInfo;
LatentInfo.Linkage = 2;
LatentInfo.ExecutionFunction = FName(TEXT(“YourLinkageFunction”));
UKismetSystemLibrary::Delay(this, 1.0f, LatentInfo, this));
break;
case 2:
// Here now, the Linkage number “2” effective
}
}