They both seem to do the same thing?
Thank you
That’s because they are effectively the same when used like this (with the OnTakeAnyDamage binding as self).
ReceiveAnyDamage (the underlying name for AnyDamage) is just a convenient binding for OnTakeAnyDamage on self.
Notice how the OnTakeAnyDamage binding you’ve made also has the DamagedActor pin- that pin would be relevant if you weren’t binding to self, since that would tell you which actor called the OnTakeAnyDamage event- it’s the same as the target that was bound.
The only place ReceiveAnyDamage/OnTakeAnyDamage are ever called are right next to each other.
ReceiveAnyDamage Declaration:
OnTakeAnyDamage Declaration:
The only place either are called:
Thank you for the reply, apologizes I’m a newbie still and don’t think I asked the question properly. The lecturer coded the bind event, after research, bind event to anything lets you call functions after an event has occurred. What I’m wondering is why would I use one over the other? Why bother binding events when I can just call the event and add functions after it? Thanks again
I’m not sure what you’re trying to say…
Binding is for when the function doesn’t have a convenient self alternative like OnTakeAnyDamage does in the form of AnyDamage, or when the target is not self.
Not every event has the convenient self binding, and you often care about targets other than self.
You can bind another object’s events to your own functions, and use the DamagedActor pin to tell which actor got damaged.
For example, say my actor wants to get notified whenever a different actor gets damaged. That’s not possible with Event AnyDamage, because the target is self. If AnyDamage is getting called, that means this actor has taken damage.
On the other hand, if you bound an event in this actor to that other actor’s OnTakeAnyDamage event, then you’d be able to do what you wanted when they got damaged.
Furthermore, if you bind multiple different actors, even multiple types of actors, then you can use the DamagedActor pin on OnTakeAnyDamage to be able to know which got damaged, and act accordingly.
So to directly answer the question, you would use AnyDamage (the self binding) if you only care about self, and bind when the target is not self.
In this case, there is no reason at all to bind. This is the exact case that AnyDamage exists for- to prevent you from needing to bind OnTakeAnyDamage when you only care about self.
oohhhh I get it a bit more thanks!
“I’m not sure what you’re trying to say…”
I was trying to say the professor of the online course I’m taking wrote that blueprint code and after researching more on the topic I found out more about what the “bind event” does but still wasn’t sure what the different was between Event AnyDamage and binding to OnTakeAnyDamageEvent. Sorry for the confusion.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.