I want to update a widget frequently across multiple actors of the same BP.
The original works fine.
I wanted to condense it into a function ( and do other things later ). When I did that and replicated the logic inside the function it stopped working. It still prints the value and it updates the position of the widget, but it fails to set the value.
you changed SupplyDepot Ref to Self on some pins but not on others so thatâs likely the problem.
also to make this much more efficient call an event dispatcher on tick and have the widgets bind to that dispatcher rather than GetActorsOfClass and a ForLoop
This. You need to pass in a object reference from your initial âget all actors of classâ.
But my brother, please do not call âget all actors of classâ on tick! It is only of the most expensive functions in the entirety of blueprints. You need to re-architect your implementation.
I would maybe recommend adding a widget component to your blueprint, looking at your implementation and without knowing more about your project.
Go to your function graph and drag the target from the âUI Supply Depotâ into the purple function starting node. That will create the input for the function.
Go to your event graph and wire in the object (blue) output of your loop into the function. Viola
I had a family vacation, came back, redid a bunch of stuff and came back to the same problem. This finally clicked it for me.
So Iâm guessing that even though the function exists within the blueprint it has no knowledge of which blueprint I am actually asking it about.
Itâs sort of weird that it works at all in that context as it still did something when I would think it should instead fail outright. Perhaps âselfâ in this context is the first actor of this class that was createdâŚa moot point I guess.
Am I correct in assuming I should make an âinteractionâ blueprint where I handle all the clicks and whatnot? ( My game would NOT have a singular character as such and would be a top-down isometric view. )
âSelfâ refers to the BP class itself. Your function was using an output of a previous execution which is not stored in memory, hence why you need a node wired in.
Regarding interaction - there are many different ways to handle gameplay interaction. If you are new, I would recommend grabbing a good-looking marketplace asset pack for an interaction system written in BP - you will be able to see how you can use BPIs & event dispatchers to send messages between actors in a âgoodâ way. You want to avoid hard-coding BP types and casting between all classes as that creates a chain of hard dependencies and increases the rigidity of your project