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"

Cannot call function library functions in blueprints

So, I've finally started doing some C++ work because I wanted to do some stuff that's apparently not possible in pure scripting or at least less neat.

As a starting point, I created a Function Library according to a few tutorials that I found online and created a few dummy functions to test the functionality first. Now, my issue is that, after compiling, (which, by the way, behaves very erratically and often throws out errors for code that it compiles perfectly fine on a second attempt) I don't see the functions anywhere in my blueprint context menu and neither do I see them in the "Palette" view. Yes, I also tried to uncheck "context sensitive".

I only have a header right now, because I am assuming that an actual implementation of the functions is not strictly necessary to make the them appear in the editor, as doing an implementation while testing in another project didn't help either. If an implementation actually is required, it would be nice to know, though.

I made three functions to test if any of the blueprint-related parameters would produce different results, and also tested if making the functions explicitly static would change anything. Which it does, by giving me a "error C2352: 'UObject::FindFunctionChecked': illegal call of non-static member function" error, even though the tutorials do use the static keyword.

The Enum also doesn't appear, but I'm not sure if it's supposed to or if there's even a way to include a C++ Enum on the blueprint side. The library is in the root folder of the C++ classes list. The shared category of Enum and the functions shouldn't be the cause of the issue, as I originally didn't have a category for the former.

 #pragma once
 #include "Kismet/BlueprintFunctionLibrary.h"
 #include "BPFunctions.generated.h"
 UENUM(BlueprintType, Category = "PowerUp")
 enum Boosts
 class GROWTH_API UBPFunctions : public UBlueprintFunctionLibrary
     UFUNCTION(BlueprintImplementableEvent, Category = "PowerUp")
         static void PowerBoost(Boosts Type, float Value);
     UFUNCTION(BlueprintCallable, Category = "PowerUp")
         static void PowerBoost2(Boosts Type, float Value);
     UFUNCTION(BlueprintNativeEvent, Category = "PowerUp")
         static void PowerBoost3_(Boosts Type, float Value);

I have seen a few posts on the topic of this issue, but most resolved with a "I restarted the editor", which doesn't work for me. In fact, I tried this in two UE versions of the same project, as well as a newly created project just for testing this one thing. As an aside, in the 4.11 version of my current 4.12 project, using the "New C++ class" functionality made a file that doesn't appear in the content browser, while the 4.12 version had no such issue.

Product Version: UE 4.12
more ▼

asked Jun 22 '16 at 04:26 PM in C++ Programming

avatar image

18 2 4 5

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

1 answer: sort voted first

UFUNCTION needs to reference your implementation function. So, at the very least, I'd include a *.cpp with an empty implementation.

Get this working with your BlueprintCallable function only. Then add in the others (note: BlueprintNativeEvent needs an _Implementation function).

An important note. The editor might not pick this up immediately and will need to be restarted & potentially compiled through the editor (just confirmed this on my end).

Hope that helps. Ping if you need more assistance.

Here's what you're looking for. I don't think Events can be static because of the way the functions need to be referenced in order to manage events.

 class CPCARPLAYGROUND_API UMyBlueprintFunctionLibrary : public UBlueprintFunctionLibrary
     UFUNCTION(BlueprintCallable, Category = "PowerUp")
     static void PowerBoost(Boosts Type, float Value); // empty implemented in *.cpp
     UFUNCTION(BlueprintImplementableEvent, BlueprintCallable, Category = "PowerUp")
     void PowerBoostAlternative(Boosts Type, float Value); // no implementation in *.cpp, handled by blueprint
     UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "PowerUp")
     void PowerBoostAnotherAlternative(Boosts Type, float Value); // no implementation in *.cpp
     void PowerBoostAnotherAlternative_Implementation(Boosts Type, float Value); // implementation in *.cpp
more ▼

answered Jun 22 '16 at 05:07 PM

avatar image

396 16 8 16

avatar image vb4 Jun 23 '16 at 08:11 AM

Thanks, this actually instantly solved my issue.

I removed the second and third function and kept the implementation of the first one (which, strangely enough, was one of the first things that I did while testing this stuff already) and now both the implementation and my Enum show up in the editor. (...And now I'm getting errors while saving in the editor, telling me that the blueprint is referencing a private external object and cannot be saved. A restart thankfully fixed that, but this could have quickly ended in data loss)

As for the static thing, I kinda got thrown off by a remark that the functions are supposed to be static functions. I know mostly the more archaic side of C++, so I was just using the keyword on the assumption that it would do something because it appeared in the example, until I could look up what it actually does.

...And only now do I get that the "Event" in the parameter literally means that the function would be made into an event.

(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