How I create global blueprint function ?

Hi

Is there a way to create a global blueprint function that I can access from any other blueprints ?

Hello,

All blueprint functions (except level blueprints) can be global. You just need to cast to them.

Not sure what you’re trying to do, so maybe I’m mistaking what you mean.

1 Like

Create a Blueprint Function Library in Content Browser for this.

BPFL

2 Likes

Thanks to all

I created one now but then I try to drag this function library into another blueprint I get this error
Can not create a node from this type of asset

You need to add a function inside your library asset and then call it from any blueprint.

1 Like

Hm, never used this before.

Does it basically behave as a cast/get actor or is it something completely different?

Unlike actors, you cannot instantiate a library yourself. In the project, it exists in a single copy, and it is within it that the function is called.
This is an analogue of static functions in C++.

2 Likes

Helpful and understood.

To call a function in any blueprint library:

  1. Drag a line from the wihte arrow and release
  2. Type in the name of the function. You can often type the function name in partially due to real time autocompletion trying to find the function as you type.
  3. Click on the function you want.

Note that you can also give your function a category by:

  1. Opening the blueprint
  2. Clicking on the function in the list to the left of the blueprint rendering area.
  3. Click on Category in the properties pane. It’s the 2nd option from the top in the “Graph” section.
  4. Type in a new category or select an existing one. You can create subcategories with a vertical bar. “Main|sub”. No spaces.
1 Like

Got it thanks. BluePrint is fun compared to C++ :slight_smile:

I have mixed feelings. Yes, Blueprint is more fun, but it’s also less powerful, slower, and even more “fiddley”. You can spend hours trying to make your blueprint look good, then find somewhere else to tweak the wires so it’s a bit clearer/cleaner than it was.

Plus, after 20+ years, I’m pretty ■■■■ good at C++. :wink:

Life is short this is why I wish I make a small fun game as indie

I found also if I have a variable in actor blueprint , I can get/set that variable in widget blueprint

Are you talking about this?

You can do this from any object, you just need to have a reference to the desired actor.

1 Like

Yes but without reference from actor

No, you definitely need a link, otherwise your blueprint will not compile…

If you remove the Context Sensitive flag, you will be able to see the COMPLETE list of nodes that can be added to this graph, but for some to work correctly (such as getting a variable), you must connect certain pins.
Therefore, with the Context Sensitive flag enabled, you would see the variable getting node only if you pulled out a pin with the type of the corresponding class within which the variable is located.

image

1 Like

I see thanks. How I can get reference to Actor without cast ?

Just create a variable of the desired class, if that’s what you’re talking about…

1 Like

Yes I did that . I created an object reference in actor blueprint 1 but when I tried to use that reference variable in the widget blueprint I get error