Hi all, so problem statement; I have a struct A, which contains a TArray of struct B. Struct B has a multicast delegate OnStatusChanged, and in struct A’s constructor, I’m attempting to bind a lambda to the OnStatusChanged delegate belonging to each struct B in the TArray.
There are no errors or anything thrown when compiling or running the bind, but when it’s called, the lambda doesn’t appear to be executing.
I suppose the question becomes - can structs bind to and execute lambdas? Is there something I’m perhaps missing?
explicit FMM_Mission()
{
FTimerDelegate TimerDelegate;
FTimerHandle TimerHandle;
TimerDelegate.BindLambda([&]
{
for (FMM_Objective Objective: Objectives)
{
Objective.OnStatusChanged.AddLambda([&]
{
GEngine->AddOnScreenDebugMessage(-1, 15.f, FColor::Yellow, TEXT("Lambda running"));
});
}
});
if (GEngine && GEngine->GetWorld())
GEngine->GetWorld()->GetTimerManager().SetTimer(TimerHandle, TimerDelegate, 1.f, false);
}