Problems with Dynamic Delegates

I’m trying to pass a singlecast delegate from my a BP to my C++ code. The Delegate has a parameter, but it’s not showing up in the blueprint when I try to assign it (when I drag out from the Server List Delegate pin on Request Server List, it creates this parameterless event with no out pins and fails to compile).

struct FServerInfo
	FString ServerName;
	int32 PlayerCount;
	FString ServerIP;


	FServerInfo(const FString& InServerIP, const FString& InServerName, int32 InPlayerCount)
		: ServerName(InServerName)
		, PlayerCount(InPlayerCount)
		, ServerIP(InServerIP)


DECLARE_DYNAMIC_DELEGATE_OneParam(FServerListRetrievedDelegate, const TArray<FServerInfo>&, ServerList);


I also can make an event in the blueprint that matches the signature of the FServerListRetrievedDelegate, but it won’t assign.

I tried switching to a multicast as well (though I don’t need it), and this is the result: Failed to Generate Code - Multicast Delegate Problem - UE4 AnswerHub

Have you tried to use a simpler set of arguments? The following as a sample I use in one of my projects (on 4.7.6):

DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FTriggerUsedSignature, class AWDPlayerController*, InstigatorPC, class UWDTriggerComponent*, TriggerComponent, FInventoryItem, Item);

And it works without issues, FInventoryItem is just a simple struct with a FName and some other simple types.

I tried it with an int32, and the param still didn’t show up in the Blueprint. And MULTICAST and EVENTS are giving me that issue I linked to on the answers hub.

I am sorry to hijack this thread but… it’s possible to create a UFUNCTION that takes a delegate as a parameter!? How?

UFUNCTION(BlueprintCallable, Category = UBGameInstance)
void RequestServerList(FServerListRetrievedDelegate ServerListDelegate) const;

That’s how I set mine up… I just mimicked K2_SetTimerDelegate. Interestingly enough, if you make the delegate a const reference, it becomes an accessor node with no output.

That’s invaluable info, thanks!

I still can’t get this working. I got around it by having the TArray owned by the GameInstance and when the BP is told the list has been updated, it will grab the list from the GameInstance. I’d rather just use the delegate, so if anyone has any input that’d be great.

Bump… Would still like to get this working properly