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"

Struct with methods


Is there any way to create the blueprint that contains data and simple methods to access it to use mostly like a structure? Something like C++ structure with member functions ...but without C++.

Thank you.

Product Version: Not Selected
more ▼

asked Apr 16 '15 at 08:42 PM in Blueprint Scripting

avatar image

3 1 2 5

avatar image quixoticaxis Apr 17 '15 at 11:18 AM

Or even created with C++ but exposed to blueprint.

avatar image quixoticaxis Apr 17 '15 at 11:25 AM

The goal I'm trying to achieve is using custom Set/Get methods on the structure from inside the blueprints.

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

1 answer: sort voted first

Try an interface. You tell the Interface what Functions are attributed to it, then when you create a blueprint it can Implement that interface, but you'll have to implement the functionality yourself.


more ▼

answered Apr 17 '15 at 12:02 PM

avatar image

197 7 10 18

avatar image quixoticaxis Apr 17 '15 at 03:09 PM

I was hoping to use member functions in a pair with interface to implement some kind of multiple inheritance. For example: 1) I have character stats like health and vitality, the firsts depends on the second so changing vitality also changes current and maximum health. This logic is implemented inside MyStatStruct methods. 2) I have IHaveStats interface with Get/Set Health/Vitality. 3) When I need to create an object that has these properties I add a variable of MyStatsStruct type with its fields exposed to the editor and then implement the interface functionality just connecting interface calls to already-programmed structure methods.

I have probably found the way to do it creating structures in c++, but I need to check this out and I can't do it now =( So I'll comment on this later.

p.s. And I know that I can achieve the same mechanics with nested inheritance but then I still need to implement get/set logic more than once.

avatar image quixoticaxis Apr 18 '15 at 06:19 PM

Update: It doesn't compile because "USTRUCTs cannot contain UFUNCTIONs". And this is kind of strange.

avatar image quixoticaxis Apr 18 '15 at 06:25 PM

USTRUCT(Blueprintable) struct FCharacterStats { GENERATED_USTRUCT_BODY()

 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Stats")
 int32 vitality;

 void SetVit(const int32 NewValue);


This compiles fine until I add UFUNCTION(BlueprintCallable, Category="Stats") for the SetVit method.

avatar image quixoticaxis Apr 18 '15 at 06:27 PM

The only workaround I'm thinking about now is creation of blueprint library with set/get functions for each of the structures I have.

avatar image quixoticaxis Apr 20 '15 at 02:05 PM

I've found this: http://thehumgame.com/tutorials-from-the-hum-1-using-c-uobjects-as-data-objects-unreal-engine-4/ But there seems to be no way to call ObjectInitializer from inside the blueprint. So back to code or static blueprint libraries.

(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