Page cover

On Health Data Changed

The "On Health Data Changed" event dispatcher is an event that is fired whenever the health data of an instance of the RHS Component is manipulated. You can bind to this event dispatcher to execute logic in any other blueprint whenever the health data gets changed.


Event Dispatchers do not manipulate any data within the component, so they are a good solution for attaching your custom logic to various events within the Replicated Health System component without actually having to access the component's internal logic. Click here to read more about Event Dispatchers.

How to bind

Using event dispatchers is quite simple. Suppose you have some sort of blueprint class in which you want to perform external logic when a particular event dispatcher is invoked. To bind to an event dispatcher, you must first get a reference to the specific component you want to bind to. Once you have the reference, you can follow the steps below to bind to any event dispatcher contained in the RHS component.

Create a custom event to call when you want to bind

To create a binding to one of the component dispatchers, you need to create a custom event in your event graph that you can call to bind to your selected dispatchers. Typically, you will bind to all event dispatchers once at the start of the game, but you are free to use this logic as you wish, as there is no predefined way of knowing exactly when to bind.

Binding to the desired event dispatcher

Drag from the component reference and find the event dispatcher of your choice. In this example, we will use the event dispatcher "MyDispatcher", which is not included in the system you can purchase from the marketplace. To bind to an event dispatcher, you need to search: "Bind event to [name of dispatcher]".

On the "Bind Event to [Dispatcher Name]" node, you will see a red squared pin named "Event". From this pin, you can now drag to another custom event that you have created specifically for this dispatcher, or to an existing event that you want to run when the event dispatcher is called. In this example, we will create a new custom event and bind it to the "MyDispatcher" event dispatcher.

Executing Logic on the new Disatcher Event

Now we basically have an event that we call whenever we want to bind to a particular dispatcher. The dispatcher itself is connected to another custom event that will be executed from there when the event dispatcher is called. From here, you can attach any kind of custom logic to the event you just created. In this example, we will show you how to print "Hello World" using the custom dispatcher event we created in the previous steps.

Using the "Print String" node, we will now print "Hello World" to the player's screen every time the "MyDispatcher" event dispatcher is called. Of course, this is a very simple example, but you can basically connect any other logic you like here, including but not limited to functions, macros, custom blueprint logic, or other events in your blueprint.

For now, you should have a working binding to an event dispatcher from the RHS component. Note that the "MyDispatcher" event dispatcher is not included in the system and is used for demonstration purposes only. The result of our logic should look like this:

Note that when you bind to an event dispatcher, the event that executes the binding, which in our case is the "Bind to Dispatcher" event, must be executed only once! After binding to a dispatcher, the new custom event (in this example, "My Dispatcher Event") will be able to be called until you unbind it. Learn more.

Unreal Engine Documentation

This guide on how to bind to event dispatchers was a fairly basic introduction on how you can use the event dispatcher included in the Replicated Health System Component. If you wish to better understand how you can work with event dispatchers in Unreal Engine or how you can create your own dispatcher events, please refer to the Unreal Engine Documentation. Below you will find some useful links about event dispatchers:

In Summary

Cover

Learn how to create your own event in order to bind to any dispatcher.

Cover

How to access the bind node for a certain event dispatcher.

Cover

Bind a custom event to the event dispatcher using the bind node.

Cover

Add logic to your new custom event, bound to the event dispatcher.

Cover

Testing the results of the new custom binding.

Last updated