Differences between functions, events, and macros in UE4 blueprints

grammatical difference

Execution pin differences:

  • Functions are allowed to have an execute pin and an output pin
  • Events are only allowed to have one execution pin
  • Macros allow multiple execute pins and read output pins

return value

Functions and macros allow return values, while events do not

It should be noted that
the function can have a return value or not. If we do not set any return value for the function, the event logo (arrow) will appear instead of the function logo (f) where we call the function, as shown in the figure below A function

that does not return a value will be treated as an event by the system. Similarly, after a subclass overrides the parent class's non-return value function, it will also be treated as an event. This can be said to be a BUG of UE4, and it can also be understood as a feature processing. The specific why needs to be further studied.

delay node

Delay nodes provided by UE4 can be used in events and macros, but functions cannot.
Some nodes are unique to a certain function, not only delay nodes, TimeLine nodes can only be used in events is also an example.

access range

  • Functions and events can be accessed across blueprint classes, while macros can only be accessed within the defined blueprint class
  • Functions can be inherited, but macros cannot be inherited, and subclasses cannot use parent class macros
  • Macro libraries can be accessed across blueprint classes

logical distinction

The calls of functions and macros are executed synchronously. It is necessary to wait for the internal logic of the function or macro to be executed before the next logical
event is executed asynchronously. The place where the event is triggered does not need to care about the internal logic of the event, and only needs to trigger the event to execute the next logic. .

Reason: Because the function or macro has a return value, the subsequent logic of calling the function or macro may be related to the return value, so it is necessary to wait for the end of their call before continuing the next logic; while the event has no return value, the logic inside the event is the same as the call The local logic has nothing to do with it, so you can execute the next logic without waiting for the event to finish executing, you just need to emit the event when the event is called.

Guess you like

Origin blog.csdn.net/weixin_44081533/article/details/125274965