Unreal AddDynamic() Delegate Is Not Working

Advertisement

There are multiple reasons why a function that was bound using AddDynamic() may not get called or appear not to work in Unreal Engine C++. This Tutorial will cover some of those scenarios and how to solve them.

Common Developer Mistakes

  1. You are not getting Delegates by reference before you call AddDynamic On Them. You should almost always get a reference to the delegate, not a copy. Example of how NOT to do it:

    FDelegateName theDelegate= getDelegateFunction();

    This is wrong and you will get a copy instead of the delegate you want to bind to. Instead, use:

    FDelegateName& theDelegate= getDelegateFunction();

    Emphasis on the ampersand sign( get by reference).

  2. The delegate is not getting Broadcast anywhere in the code. If Delegate->Broadcast is not getting called anywhere in the code, that means listeners(functions) will never get triggered. Sometimes this may be your error if its a custom delegate or a bug within the engine itself if its an engine delegate. The delegate may not have ever been called.

  3. Garbage Collection. Check if your delegate owners or broadcasters are not getting deleted on invalidated by the garbage collector. Ensure you have protected/or added them for reference counting by using UPROPERTY where appropriate.
5/5

Gamechanger plugin for notehighway rhythm games and music visualizers

5/5

Add Text and 2D UMG widgets to Level Sequences

Consider investing in some of our plugins. They might save you some time.  Also helps supports these tutorials.

Instantly get access to our plugins like Blender Curves Importer and UMG Cinematics and more when  you support us on Patreon!

 Join Us On Discord For More Daily Tips!