What difference between delegates?

Good day!

Can’t find good article about it, so I decided to make a question about it.

  1. What the difference between Dynamic and Multi-cast Delegates?
  2. Is any difference between Multi-cast Delegates and Single-cast Delegates except of amount of handling functions (single cast have only one?)
  3. What difference between Events and Multi-cast Delegates? Which way the most appropriate for using them?
  4. How can I know which object was called this Delegate? I can use object pointer as variable? Is it safe?

If someone have already answered this questions, feel free to throw a link into my face!

1 Like

1. What the difference between Dynamic and Multi-cast Delegates?

Dynamic Delegates can be serialized. When you don’t know if you need a dynamic delegate, you probably don’t need one and you should go for Multicast Delegates instead.

2. Is any difference between Multi-cast Delegates and Single-cast Delegates except of amount of handling functions (single cast have only one?)

Pretty much on point, singlecast is pretty much a direct function pointer, multicast is an array of function pointers. (with some unreal precompiler magic attached)

3. What difference between Events and Multi-cast Delegates? Which way the most appropriate for using them?

They are the same thing with different names in BP and C++

4. How can I know which object was called this Delegate? I can use object pointer as variable? Is it safe?

There is no default way that I am aware of, but just passing this works, if set up properly.

6 Likes

Old post, but wanted to clarify the info here for others that find this while searching (like myself).

1. What the difference between Dynamic and Multi-cast Delegates?
To add to the above post, Dynamic delegates are also the slowest of all delegate types. Don’t use them unless you must.

3. What difference between Events and Multi-cast Delegates? Which way the most appropriate for using them?
Events are different than Multi-cast delegates, even in cpp.

If you don’t need more than one class to do the broadcast, use an event.

4. How can I know which object was called this Delegate? I can use object pointer as variable? Is it safe?
If you only need to know who called it (for example, while debugging), print the result of GetName() in the bound function.

You can pass an object pointer as a variable. I have never encountered any issues while doing so.

2 Likes

I want to do this Allow to press a button when the player is close enough to it. All the players are instances of the same class. Do I need an event instead of a Muti-cast delegate?

Thanks.