Defining events
Event dispatchers in NimForUE allow you to create events that can be easily subscribed to in Blueprints. This is useful for creating modular and extensible gameplay systems.
Defining the Delegate
First, define your delegate type using the uDelegate
macro:
This creates a multicast delegate type that takes an AActorPtr
(representing the enemy) as a parameter.
Adding the Event Dispatcher to Your Class
In your class definition, use the uprop
macro with the BlueprintAssignable
specifier to create the event dispatcher:
Creating a Function to Trigger the Event
To make it more accessible in Blueprints, add a function to trigger the event:
Complete Example
Here’s a complete example combining all the steps: