Remove Mutlicast Delegate

Hi,

I’m having problems using multicast delegates.
I wrapped a controller-class around the GameSession to make the usage from cpp and blueprint easier.

But currently i have a weird problem.

In the controller-class and my GameSession-class I’m using events to bind to the completion of e.g FindSessions.
Based on the ShooterExample I’m using remove() on the DelgateHandlers to unbind from it.
But even through I call that remove() function the DelegateHandler is still valid afterwards. An when I rebind to that event later a breakpoint will be reached saying the following:

Assertion failed: !DelegateInstanceInterface->IsSameFunction(*InDelegateInstance) [File:d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\runtime\core\public\delegates\DelegateSignatureImpl_Variadics.inl] [Line: 781]

I have no idea how to properly unbind from that delegate.

Also I don’t even know why the shooter example is rebinding every time. Wouldn’t it be better to just bind on e.g. init and then let it bound till the end of all time?

Here the declaration of the events:

Here the getter functions:

Here the binding:

Here the remove:

Hi there :slight_smile:

Take a look at this wiki tutorial, exactly on your theme.

There are delegates binded ones (in game instance constructor):

OnFindSessionsCompleteDelegate = FOnFindSessionsCompleteDelegate::CreateUObject(this, &UMyGameInstance::OnFindSessionsComplete);

And after that you can add and remove handles like this:

OnFindSessionsCompleteDelegateHandle = Session->AddOnFindSessionsCompleteDelegate_Handle(OnFindSessionsCompleteDelegate);
Session->ClearOnFindSessionsCompleteDelegate_Handle(OnFindSessionsCompleteDelegateHandle);

Hth