x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Pass Content Window Actors/BlueprintFunctionLibrary to C++ Function.

Hi,

i would like to know how I can pass the actors or my BlueprintFunctionLibrary in my content window to c++ functions. Is there a way to do that?

Basically pass this:

alt text

to this:

alt text

It would also be ok if I could just use a UPROPERTY:

alt text

But I cannot select this library, why does it not show up in this list?

alt text

What can I do to access this function library?

Product Version: UE 4.20
Tags:
1.png (45.1 kB)
1.png (4.2 kB)
1.png (8.0 kB)
1.png (33.7 kB)
more ▼

asked Oct 29 '18 at 04:33 PM in C++ Programming

avatar image

DasOhmoff
1 3 5

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

I think you misunderstanding the role of BlueprintFunctionLibrary. Technically you can do blueprints nodes on in any UObject and AActor based class (so practically anywhere), BlueprintFunctionLibrary only exists for static functions for nodes that you can not logically relate to any of the classes you have or you want to or you want to make node out of something that can not be direly exposed to blueprint (like non-UObject class or C++ struct functions).

For example all math functions in C++ inside UE4 are packed to FMath structure, blueprint don't support functions in structures and also math operators from C++ (aspecially for premitive types) can not be bind to blueprint, there for UBlueprintFunctionLibrary class was made called UKismetMathLibrary (Kismet is node scripting system in UE3 and blueprint suppose to be Kismet 2.0 thats why you can still see that name in UE4) which contains static function with all math operations which are bind to blueprints, and only reason why they are there is due to limitations of blueprints.

What im getting at? Those libraries suppose to only contain static functions and object for then should not be never created, if you corner yourself to need to pass blueprint library as object that means you doing something wrong. if you want to create node for object it should be in class of that object, if you need global variable for any node operations you place those in either GameMode or GameInstance or PlayerController. So you probably need to reconsider what you doing, you didn't explained why you doing this so i can't really suggest you anything here.

Now the reason why you don't see those object is something compliantly different. You can see object in property editor only in those cases:

1.Object you trying set property in exists on the level (this includes World Settings and Level Blueprint) and object you trying to set property in exists in exact same level

2.Object is registered asset on content editor (like UTexture, UStaticMesh etc)

Reason why you can do that only in those cases is because you making a class not a object and when object of a class is created there no guaranty that selected object will exists on creation of that object, or else those consitions are met. If you have object already created on the level editor there guaranty that other objects saved on the level will also exist, thats hwy you can select them, if you spawn object of class in any other moment there no guarranty that those object exist anymore... there no guarranty you spawn on same level you editing, how UE4 suppose to know that? thats why you can not to do that on raw blueprint class. While assets in content browser exists in asset registry and will be packaged in the game so UE4 can also ensure of existence of those objects in any moment.

You can only select class (UClass* or TSubclassOf) anywhere and then create object of it in the blueprint.

If oyu don't understand, think blueprint as C++ class (because thats essentially what it is) and in C++ you can not just grab C++ class and call function on it or else functions are static, you need a object to be made of that class, blueprint is exactly bound to same limitation. "Class" as name suggest just defines class/type of objects not the object instance.

more ▼

answered Oct 29 '18 at 09:45 PM

avatar image

Shadowriver
36.7k 932 169 1111

avatar image DasOhmoff Nov 03 '18 at 10:12 AM

Yes I see. But are the function library functions not static? In C++ when I create a class and a static function within it, I do not have to create an instance of that class to call the static function. That is what I want to do with the function library. Basically my function library has a function called "PrintScreen". Because I created that function in the function library I though it would be a staic function and I would not have to create an instance of this "class" (this blueprint) to call it. So this is basically what I want to do, I want to call the function in the function librarary without creating an instance of the blueprint "class". In C++ I would just include the header file and call the static function. In blueprints I thought that I would have to pass the blueprint as a property and call the static function with the passed property. I see that this does not seem to be correct. So how would I do that with blueprints (calling static blueprint functions from the function library in c++)?

avatar image Shadowriver Nov 03 '18 at 05:29 PM

No, again there nothing special about BlueprintFunctionLibrary is practically empty class just made to store static functions, you need to declare static functions like this:

 UFUNCTION(BlueprintCallable)
 static void SomeFunction();

And oyu can declare static functions in any class and structure, but to make blueprint node out of those you need to do it in any UObject

Static function uses class they are in just as namespace and you don't need any instance of object to call it just call it like this

 UMyFunctionLibrary::SomeFunction();

avatar image DasOhmoff Nov 03 '18 at 07:35 PM

Thank you for the answer. I understand what you are saying, at least I think so, but I did not decleare the function in c++. I decleared the function as a blueprint. So basically like this:

alt text

As you can see, there is no c++ source or header file. What I want to do is either "#include" the blueprint somehow to call the function, or pass the class in some other way to call the function. What I am trying to say is that I cannot call the function without including or passing something, because it would be not definined then. I need to give c++ some kind of definition of this function so it can be called, wheter it is through an include or not I do not know.

Maybe I am just beeing stuped right now, and if so I apologize for that, seems like I am not a very smart man.

1.png (98.1 kB)
(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question