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"

C++ FunctionLibrary error in Blueprint

Hi,

I just got a problem with a FunctionLibrary. This is the fist time I tried create a new one and I'm new to programming in general so I'm going to describe exactly what I did:

1: I went to File > Add Code to Project and choose Blueprint Function Library.

2: I added the following code to the library:

header:

 UFUNCTION(BlueprintCallable, Category = "Test")
         UObject*GetDefaultObject(TSubclassOf<UObject> ObjectClass);

C++:

 UObject* UMyFunctionLibrary::GetDefaultObject(TSubclassOf<UObject> ObjectClass)
 {
     return ObjectClass->GetDefaultObject();
 }


The node can now be used in a Blueprint. But when I try to compile I get an Error: alt text

I have found the Code for the Function in the Internet but it was only the C++ part. So I tried to do the rest on my own.

I'm a little confused now. Maybe you can tell me, what I have done wrong.

Product Version: Not Selected
Tags:
more ▼

asked Apr 08 '15 at 02:25 PM in C++ Programming

avatar image

Excalibro
3 2 1

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

1 answer: sort voted first

"Target" should pin points to object on which the function is called on, it is required to plug somthing to it or else VM won't know to which object call a function. If you want to create function not realted to object of this class you need to create static function, you only need to add "static" to function decleration in header file:

  UFUNCTION(BlueprintCallable, Category = "Test")
  static UObject* GetDefaultObject(TSubclassOf<UObject> ObjectClass);

This way Target pin will disapper and you won't need to deliver any object

more ▼

answered Apr 08 '15 at 02:32 PM

avatar image

Shadowriver
36.7k 932 169 1111

avatar image Excalibro Apr 08 '15 at 02:58 PM

Thanks it worked:)

(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