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"

How to store 'this' pointer to UBlueprintFunctionLibrary?

I created my UBlueprintFunctionLibrary-derived class with member functions and private variables.

I'm using it from blueprints by creating an instance of that class with the construct object from class node. My question right now is: how do I store the this pointer to the object just created? How do I store the object just created so I can call another member function later from blueprint?

I managed to set a very generic Object type variable with the object reference return value from that node, but I can't cast it back to my UBlueprintFunctionLibrary-derived class afterwards.

Product Version: UE 4.15
Tags:
more ▼

asked May 10 '17 at 08:28 AM in Blueprint Scripting

avatar image

Eka
18 4 4 10

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

2 answers: sort voted first

engineering wise is not the best you wanna do. anyhow, "this" pointer is of a specific class. you can make a function that take that type of pointer as input and assign it as to the private variable.

second way is that if your class has a static pointer of itself that will be initialized at creation. then in your blueprint library you can access that self reference ( this however is limited to one pointer per class since it's static )

more ▼

answered May 10 '17 at 09:19 AM

avatar image

plangton
352 17 20 31

avatar image Eka May 10 '17 at 02:06 PM

Thank you, what would work best in this case? I mean: having a C++ stateful class with functions and events that can be used from blueprints. If UBlueprintFunctionLibrary isn't the best choice, what alternatives do I have?

avatar image plangton May 10 '17 at 02:42 PM

yes, UBlueprintFunctionLibrary is equivalent of an static class. now in such case you can't have all the pointers stored. perhaps if you can elaborate more why you ee such case i can help you more.

avatar image Eka May 11 '17 at 07:09 AM

Sure, I need to initialize something OS-specific when a blueprint node is called and then keep it active for the entire duration of the program. Then deinitialize it when another blueprint node is called. This stuff has plenty of OS-specific pointers, handles and the like so I need a class instance to store them.

(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