What I’m trying to do is have other objects request UGlobalEventObject a binding to the OnGlobalEvent delegate, who would then bind the event of an interface they implement for them. The idea is I’ll simply pass a set of tags to the UGlobalEventObject from whatever object I need bound, and it will automatically bind it to the corresponding delegates based on the tags. Code is as follows:
//.h
DECLARE_MULTICAST_DELEGATE_FourParams(FGlobalEventDelegate, FGameplayTagContainer, const FGlobalEventStruct&, int32, bool);
FGlobalEventDelegate OnGlobalEvent;
UFUNCTION(BlueprintCallable, Category = "")
bool RequestDelegateBinding(UObject* Requester, FGameplayTagContainer DelegateTags);
//.cpp
bool UGlobalEventObject::RequestDelegateBinding(UObject* Requester, FGameplayTagContainer DelegateTags)
{
OnGlobalEvent.AddUObject<>(Requester, &IGlobalEventInterface::OnGlobalEventReceived);
return false; //Placeholder so it compiles
}
I get an error on the AddUObject line, saying
error C2664: 'FDelegateHandle TBaseMulticastDelegate<void,FGameplayTagContainer,const FGlobalEventStruct &,int32,bool>::AddUObject<UObject,>(UserClass *,void (__cdecl UObject::* )(FGameplayTagContainer,const FGlobalEventStruct &,int32,bool) const)': cannot convert argument 2 from 'void (__cdecl IGlobalEventInterface::* )(FGameplayTagContainer,const FGlobalEventStruct &,int32,bool)' to 'void (__cdecl UObject::* )(FGameplayTagContainer,const FGlobalEventStruct &,int32,bool)'
I’m obviously doing something wrong here, but I can’t seem to find any documentation on this, all I find are examples of how to bind a function to a delegate on the very same object, e.g.
OnGlobalEvent.AddUObject<>(this, &IGlobalEventInterface::OnGlobalEventReceived);