My understanding is that the error is occurring because the same delegate is being added twice. I see that it is already in the InvocationList when trying to add it a second time. It is the result of this ensure() from ScriptDelegates.h:
// Verify same function isn't already bound const int32 NumFunctions = InvocationList.Num(); for( int32 CurFunctionIndex = 0; CurFunctionIndex < NumFunctions; ++CurFunctionIndex ) { (void)ensure( InvocationList[ CurFunctionIndex ] != InDelegate ); }
The second time it is added, and what triggers the error, is from my BeginPlay(). The problem that I am trying to solve is how and why the delegate has been bound the first time. The binding is already there before my BeginPlay() and PostInitProperties() is reached.
I did some debugging after starting a PIE play session:
Looking at the stack frame for ULevel::Serialize(), I was able to access the level’s array of actors:
/** Array of all actors in this level, used by FActorIteratorBase and derived classes */
TArray<AActor*> Actors;
The actor in question was in this list of Actors, with the delegate already bound! Since this is the call chain triggered by just starting a PIE play session, it seems that the delegate is already bound when the PIE session is still being initialized.
As I mentioned in my previous post, creating a fresh Blueprint for the Actors seems to solve the problem. That makes me think that the first delegate binding is somehow tied to or ingrained in the Blueprint.
I included some basic steps to reproduce in my original post, so if anyone has any questions or is able to reproduce or pin down the issue, please let me know.
The source of the problem was moving a dynamic multicast delegate binding from BeginPlay() to PostInitProperties(). That alone resulted in the duplicate delegate error (see ensure() above). I have since moved the binding back to BeginPlay() but I am still getting the error.
