USE A LOCAL FUNCTION IN ESTERNAL BPS?

Hello ev! :slightly_smiling_face:

I made a Blueprint Interface implemented in multiple different bps, so at 1 call x of them could responde and execute. Now, If I’m not wrong, I know is not possible to refer a local bp’s variable inside a BPI function. And I would use some nodes I collapsed into a normal function, I wrote inside a single bp, as response to the shared interface function. But I can’t call this local function from esternal bps, so I tought to create a function library to add this one and solve.

In your opinion, makes it sense? Or is there a better way to do the same thing? And also, if this local function uses variables contained only inside a single bp, Should I recreate each of them in other bps or UE do it in auto?

Thank y’all so much!

1 Like

Only the blueprints you call the interface on will respond. You cannot access any internals of the blueprints, that’s the whole point of an interface :slight_smile:

But, each blueprint can respond to the interface call by running a function that comes from your function library.

They can also return variable values, but you need to define that in the interface call.

1 Like

Ye this is what I’m trying to do :slightly_smiling_face:
But I’ve never done before, I mean BPI that works within a function library.
Basically, of all the bp in which I have implemented the bpi, they would need 2 calls. One that executes a code that is the same for all (which is what I would put in the function library) and another call to execute codes that are distinct from each other. And I have some doubts about the library, because this local function uses variables that have been transmitted via another bpi. And I am not sure how I can reuse these precise variables inside a function library. And also, the function I created locally, do I have to recreate it from 0 in the library, or is there a way to “convert” it from local to global?

Anyway, thank you!! @ClockworkOcean

1 Like

The BPI call only sends a signal. It’s up to the blueprint to decide what to do with it, and may include

1 Nothing
2 Running code that calls part of a function library

If you’re running two interfaces, one for the main call, and one for the distinct stuff, you’re missing the point of BPIs. The whole reason for having BPIs, is you should not know what is happening inside the blueprint. Whether a given blueprint calls stuff or not, is no business of the BPI.

I think local variables are part of a function library, you don’t need to worry about that :slight_smile:

No, you need to put a copy in the library, and go back to all the blueprints that call it and replace that part.

1 Like

I mean, inside the same BPI, I made 2 functions. And I use them to trigger(call) 2 actions. One is equal for all of bps (for this I tought bpi+function in library) and the second one is different for each of them. Infact I’m not worried about the second one. I’m a bit confused about the library.

1 Like

You can have as many calls in a BPI as you like, of course.

You’ve right here, one BPI call, which can have different implementations in each blueprint, this is correct

Function libraries are not related to BPIs. If you have to keep writing a function in your blueprints call something like ‘find nearest door’. It just makes sense to define this in a function library, because then you can just call it anywhere you want, and you don’t have to keep manually tell each blueprint how to do it.

Thank you sir, anyway. I’m feeling a bit stupid rn to be honest ahah because, if i go it, I just have to define my “local variables” as input/output. Right?

1 Like

What do you mean by local variables? Can you give an example of what you’re doing?

1 Like

Yes I will try to be as brief as possible.

1 Like

I created a bp that has the sole purpose of doing all the get to obtain valid references of the most important bps. So as to avoid having to do the same get actor of class x times towards the same target, in y bps. So, this bp, has a local function with which it takes, validates and then transmits the refs to the bps that need them. This has to do with the first point, because, the refs are transmitted in arrays to avoid overwriting, and when the call arrives they must similarly filter the refs, keeping them all in a temporary array for future use with the exception of the self ref. Instead, the second call concerns a bp that identifies the current lvl and transmits it without a prefix, so that then each bp that receives , uses the current lvl to compile maps, in its own way, which I need to avoid/deactivate assets not related to the level.

@ClockworkOcean

1 Like

In the first case, if the BPI is passing references of type ‘actor’ then that sounds ok. If it’s passing specific types, then there’s no point in using a BPI :slight_smile:

If an array arrives from the BPI, it’s fine to copy it into a local array, of course. In fact a local copy is automatically made as part of the call, so you don’t have to explicitly do it. The different BPI calls will not get muddled up.

Transmitting a level name is fine also.

1 Like

Example of local functions i made



Another local function that calls and send all refs to each of them

An example of first call (equal response)

@ClockworkOcean

[quote=“ClockworkOcean, post:11, topic:2479422, username:ClockworkOcean”]
will not get muddled up.

AH :sweat_smile:

So I don’t risk overwriting, if I send them as single instead of array? And for the function to be rebuilt in the library, I basically just have to “rewrite” it there?

@ClockworkOcean

I rewrote the function code in the library, but now I have a warning on the self reference node “cannot be used in a static function”. And I have an error on the array I recreated, which says “SaveBpRefs.Bp_Valid_List is not blueprint visible (BlueprintReadOnly or BlueprintReadWrite). Please fix mark up or cease accessing as this will be made an error in a future release”, but I don’t have these settings from here??

1 Like

I solved this one just using a diff name for the var inside the function and the var in the return node. But the self ref warning is still there and some data is lost during the global function. Suggestions? @ClockworkOcean

1 Like

I seem to be able to make a reference to Self in a blueprint library function

Are you doing it differently?

1 Like

I took a look at your code. You seem to be collecting references of a certain class.

But what happens once you’ve got them all?

What are you going to do then?

I get that you’re trying to avoid using ‘get actor of class’ all over the place, but I think there might be a better way.

1 Like

strange… I don’t think I’m doing differently

Basically I’m trying to keep the bp still until they have received the main refs (of those bps that are closely related to each other for the functions they perform) and until they have received the current level. So the self ref I wanted to refer to the “current” bp that responds to the call and then performs the function. Where simply among the refs it has received it filters its own ref.

1 Like

Ok, but does it work?

When you mouse over the error on the Self node, what does it say?

1 Like

@ClockworkOcean Not properly.
It should keep 3/4 ref, instead it only keeps its own ref when it should have ignored it.

1 Like