need help with a event dispatcher and apply damage

so in this widget called select opponent i create a dynamic number of select opponent button widget like this

in the select opponent button widget i call this dispatcher

and i bind it in the level blueprint but i’m not sure what to connect the target node of the bind event to attack enemy,
also i’m not sure how to connect the damaged actor node of apply damage so that the correct enemy is attacked

any idea how to connect those two nodes?

Rule Number 1 - never script stuff like that in the Level Blueprint. :innocent:


The widget that has the dispatcher. Which you cannot do because the LB has no idea the widgets exists. It would need to reach out to whatever entity created that is referencing the widget - and that’s - while, probably, doable - that’s a lot of poor architecture that will give you more & more headache from now on.

i’m asking becuase when i try to use the select opponent button widget that has the dispatcher it doesn’t appear as an option

I fully understand why you’re asking. It’s a common mistake (LB has a very specific use case scenarios) and not something you’d script in the LB.


The enemies you want to damage are here:

so i bind it there?

You have all the elements here, including this bit:

You would otherwise be missing as well in the LB.

is this correct?



for some reason it doesn’t seem like it’s working, i’ve set up the event any damage in the enemy class and the change health event is for reducing the hp bar but the hp bar remains full despite clicking the button for attacking the enemy which has the event dispatcher

1 Like

It probably works, just not the way you think - which enemy do you think this is referring to:

Some stale actor ref from when the Loop run last time? Probably the very last index providing the data is still cached there.


You are telling each widget which opponent it should refer to, that’s great :+1::

The dispatcher in this widget should broadcast that information:

When you bind to this dispatcher you will get a reference of the enemy (SelectOpp) that needs attacking:

Pseudoscript but it should fit into your setup.

so wait what should i do with select opp here

and how do i make it appear in the custom event?

Select the dispatcher, and add a new input param:

Type should the same as the variable reference you want to broadcast.

is the select opp’s type in the image above ok or should i turn it into enemy or something else?

You can keep it as an actor type for now. But eventually you may need to have it as the actual enemy type.


I’d make it Enemy type:

Could be easier to work with it further down the line.

do i connect this input with something because it still shows no differences in hp despite me clicking the button
also i made a small change and connected the bind at the completed part of the loop

Yes:

Have the dispatcher broadcast the enemy reference you gave it when the widget was created.


This goes here:

Note:

did these things but still no reaction from the hp bar


This looks fine:

  • ensure that you’re not sending 0 damage
  • does the Event Any Damage trigger?

looks like damage is done right it

is there any problem in the enemy blueprint then?

Assuming this is the widget update:

This needs to be connected to update the widget.

1 Like

yeah that’s it, thanks a bunch

1 Like