I love the functionality of the existing nodes “Bind Event to On Take Any Damage” and “Apply Damage”. I’d like to mimic them for other variables I assign my actors components. For starters I’d like to build a custom “Bind Event to On Receive Any Healing” and custom “Apply Healing”. I’ve been trying to do this with event dispatchers and blueprint interfaces with no luck.
- create a new interface:
- the actor/comp that implements the interface fires a dispatcher:
You will need to cast to register the dispatcher, ofc. Unless you work it all in into a custom base class.
Or have the component reach out to the owning actor and call another interface.
Thank you! I was able to get it to work with an interface, but I’m still having an issue when trying to use an event dispatcher instead. Trying to figure out the event dispatcher method is more educational at this point, but I’m having issues with the event dispatcher’s “Bind Event to…” node. Specifically I can’t seem to get a good reference for the “target” property of the “Bind Event to…” node.
My understanding is the “target” should be the actor/actor component on which I created the Event Dispatcher. But how do I get a reference to that actor/actor component on the blueprint with “Bind Event to…” so that I may connect it to the “Bind Event to…” node’s “target” property?
I created a variable on the actor with the event dispatcher to save a reference to that actor, but when I “get” that variable into the separate blueprint where I’m trying to implement the “Bind Event to…” node, the variable too needs a target input. Seems like an infinite loop.
I have used an event dispatcher successfully to update an HP bar widget and text widget based on a changing HP variable. The “target” I use on the “Bind Event to…” node is the Actor Component with the relevant HP information and the created event dispatcher. I get this target into the the widgets’ blueprint event graph by executing a “Get Player Pawn” to a “Get Component by Class” and that feeds the “Target” property of the “Call” node. “Get Player Pawn” works here because it just so happens that at the moment I only want the HUD to display the Pawn’s HP, but this might be an issue if my controller posses a different pawn in the future and I still want to still display the original Pawn’s HP (i.e. using vehicles).
But I don’t think I can use “Get Player Pawn” for what I want since the actor with the healing event dispatcher on it is a collision sphere and not the pawn. So is there a node similar to “Get player pawn” that can instead get the actor with the event dispatcher on it? Or is there something similar in functionality for event dispatchers as “Does Implement Interface” so I could do a branch check the actors I’m getting?
Can you you describe a scenario in which the above system would be used? What really happens in game? You mentioned this functionality goes into a component (what kind of components?) and it has something to do with healing. Without going too deep into any technicalities, from the gameplay’s perspective.
There are too many ways to obtain a reference in order to bind a dispatcher but each and every one of those ways is circumstantial and choosing the right method depends on the given scenario.
Absolutely, and thank you for taking the time to help me think this one through. Now, the below is caveated with “I’m a novice”, so the underlying premise of my thought process may very well be flawed.
I’m trying to create a health component that I can add to any number of blueprints, NPC enemies, allies, other player characters. I’d also like to create ability components, such as healing, that I can drag onto those same blueprints to give them the ability to affect the HP component of themselves and also others depending on the particular ability. To begin learning how this process might be done, I’ve set up an HP component with various variables for current HP, max HP, HP regen and added this actor component to the starter content’s third person player character blueprint. I’ve created a pick up item, a sphere with collision, that the player character can walk into. I want that collision to be detected and identified as the sphere trying to change the “HP Current” variable of the HP component that has been attached to the colliding third person player character. I noticed that the apply damage sphere I created was extremely simple using the UE5 built-in “Bind Event to On Take Any Damage” and “Apply Damage”. I’ve watched some videos on event dispatchers where one person claimed those two nodes were essentially build-in event dispatchers, so I was hoping to create my own event dispatchers that would have similar functionality for many other events, i.e. apply healing, apply heal over time, apply an “on fire” condition, apply a “is frozen” condition, etc. Perhaps that video I watched over simplified those build in damage nodes and they are closer to interfaces under the hood rather than event dispatchers? Perhaps several interfaces with many custom events are the way to do this so that I can attain that modularity I’m trying to get by creating components that can be added to blueprints that should have the functionality.
Grateful to hear any thought you have on that, and thanks again!
I want that collision to be detected and identified as the sphere trying to change the “HP Current” variable of the HP component that has been attached to the colliding third person player character. I noticed that the apply damage sphere I created was extremely simple using the UE5 built-in “Bind Event to On Take Any Damage” and “Apply Damage”.
- a healing orb the player walks into
- it fires an interface message to
Any Other
actor
- this is a
AC_Health
components (you described) - it has its own stats and manages them
- it also fires a dispatcher once it’s done healing so another entity can get an optional callback
- an actor who receives the heal from the orb (at the very bottom)
- it can be setup to look up a component or you can use a direct reference (depending on how modular this needs to be - can we have more than 1 health comp, perhaps 1 for every limb and organ?!)
I’ve been preaching about actor components for a while now, it’s a great approach.
Thank you so much for your insight on this topic! I’ve been practicing and implementing your suggestions and its solved many of the other issues I’ve been running into when communicating between blueprints. Also appreciate the help you’ve been providing on tis forum over the years; I stumbled across a few of your posts on other threads and they’ve helped me greatly too!