Do binds always get overwritten?

I am giving a simplified example of my issue I ran into

So lets say I have this For-Loop that goes through a list of actors and binds a custom event to when the actor is clicked. Getting the name from the actor on clicked.

BIG FAILURE: This doesn’t work because whenever ANY actor is clicked it will give me the data of the last actor that ran in the loop

My issue is that, every time the for-loop runs, it overrides the data being sent inside the custom event

I would rather not

  1. bind a new event for every actor, and then have to create possibly endless events

  2. store a hard reference of the current actor open in the editor inside of every actor in the array

Obviously my idea of how the binds work are very lacking. I would like to know how I could set up multiple binds to one event or function without resetting the values of every bind each time I run the loop. or if using binds all together for this case is not correct pls lmk!

Let me know how to tackle this problem! :pray:

If you want an action to be triggered on each iteration of a loop, you don’t need to use binds and can just plug the code that you originally connected to your custom event into the Loop Body pin of your For Each Loop node.

I forgot to add that you should also trigger the loop after the click event, like @Extrone pointed out :grin:

2 Likes

That’s because you’re connecting the array element from the loop to Get Object Name.
The Loop runs at Begin Play, it’ll have finished looping through the array before you even get a chance to click.

When you click and Get Object Name fires, it’s getting the last Array Element that was cached in the For Each Loop node.

Use Touched Actor pin from GET NAME OF CLICKED ACTOR Event instead.

4 Likes

while this was frustrating to read at first because it was only an example and i didn’t realize it had an output pin so even my example is stupid,

but then i realized the answer was in the picture. If I have an event binded to a dispatch, and i dont want my info to be to be overwritten, I just add the data as an input pin in the dispatch and that way I get the data from the actor through the dispatch and not the for loop pin.

Thank you to the people who took my question seriously even though i did not pay attention

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.