Converting blueprint to function stops it from working

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.

Am I calling something incorrectly?

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.

Yea I figured tick was overkill. I’m still very much in my infancy.

So this - “You need to pass in a object reference from your initial ‘get all actors of class’.”…doesn’t connect in my head.

What do I do with ‘Out Actors’ then?

Sorry for being obtuse.

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

1 Like

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 :slight_smile:

1 Like

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