Difference between AddDynamic & AddUniqueDynamic?

I have tried to find it on google, UE4 wiki, answer and forum but still can’t figure out what difference between them although they have same result. Actually, I can’t find anything that relate to AddUniqueDynamic.
Sorry about my bad English!

2 Likes

Consider the following fabricated situations :

Situation 1 :
Tank->OnTankDeath.AddDynamic(this, &ATankPlayerController::OnTankDeath);
Tank->OnTankDeath.AddDynamic(this, &ATankPlayerController::OnTankDeath);

Situation 2 :
Tank->OnTankDeath.AddUniqueDynamic(this, &ATankPlayerController::OnTankDeath);
Tank->OnTankDeath.AddUniqueDynamic(this, &ATankPlayerController::OnTankDeath);

If you were to then call : OnTankDeath.Broadcast();

For situation 1 , ATankPlayerController::OnTankDeath would be invoked or called twice.
For situation 2 , ATankPlayerController::OnTankDeath would be invoked or called only once.

Essentially AddUniqueDynamic adds the dynamic delegate only if it isnt already present in the list of invocable dynamic delegates associated with OnTankDeath.

3 Likes

Thank you very much! Now I have a better understanding of delegate system :smiley:

I had the same thught. And finding anything online about it is a pain. Just curious on how would we get to it on our own?

Privacy & Terms