Unbind dynamic multicas delegate

Hi!

I’m using Unreal 5.3.2.

I had this delegate:

DECLARE_DELEGATE(FOnStopDelegate);

But I have changed the declaration with this one:

DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnStopDelegate);

And this has changed also:

public:

	UPROPERTY(BlueprintAssignable)
	FOnStopDelegate OnStop;

I have changed the binding, but I don’t know how to change the UnBind()

void UTBlocksSpawnerSubsystem::CreateFallingBlock()
{
    FVector StartLocation;
    if (GetFallingLocation(StartLocation))
    {
        CurrentFallingBlock = Cast<ATBlock>(GetWorld()->SpawnActor(BlockActorClass, &StartLocation));

        if (CurrentFallingBlock)
        {
            CurrentFallingBlock->OnStop.AddDynamic(this, &ThisClass::BlockStopped);
        }
    }
}

void UTBlocksSpawnerSubsystem::BlockStopped()
{
    UE_LOG(LogTemp, Warning, TEXT("BlockStopped - %s"), *FDateTime::Now().ToString());

    CurrentFallingBlock->OnStop.Unbind();
    
}

How can I change CurrentFallingBlock->OnStop.Unbind(); to use it with a Multicast delegate?

Thank you.

Hey @ViaCognita

Same signature as the AddDynamic, to “UnBind” you would use RemoveDynamic
In your case OnStop.RemoveDynamic(this, &ThisClass::BlockStopped).

You also have .RemoveAll

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.