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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Should my Data Objects be UStructs or UObjects?


 (Key UStruct Definitions Above)

 struct FPaperSkeletonTimelineData
         // UPROPERTY()
         // struct FPaperSkeletonAnimationData* Owner; <-- Throws error, saying "*" cant be added to a non-exposable type.
     // Unique ID
     FName Name;
     EPaperSkeletonDataType DataType;
     // Keys
     TArray<FPaperSkeletonBaseKeyData> Keys;
     FPaperSkeletonTimelineData(FName timelineName, TArray<FPaperSkeletonBaseKeyData>& keys)
         : Name(timelineName), Keys(keys)

     FPaperSkeletonBaseKeyData FindKey(float atTime);

 struct FPaperSkeletonAnimationData
     // Skeleton Data (Owner)
     class UPaperSkeletonData* SkeletonOwner;
     // Name of the Animation
     FName Name;
     // Duration of the Animation
     float Duration;
     // Should the animation loop?
     bool bShouldLoop;
     // Timelines/Objects relative to the Animation 
     TArray<FPaperSkeletonTimelineData> Timelines;
     FPaperSkeletonAnimationData(UPaperSkeletonData* skeletonOwner, FName animationName, float duration, bool shouldLoop, TArray<FPaperSkeletonTimelineData>& timelines)
         : SkeletonOwner(skeletonOwner), Name(), Duration(duration), bShouldLoop(shouldLoop), Timelines(timelines)
     bool IsActive(FName objectName);
     FPaperSkeletonTimelineData FindTimeline(FName objectName);

 UCLASS(BlueprintType, meta=(DisplayThumbnail="true"))
 class PAPERTESTREALM_API UPaperSkeletonData : public UDataAsset
     // Skeleton Name
     FName Name;
         // Definition of Objects that need to be created for the Skeleton
     TArray<FPaperSkeletonObjectDefinition> ObjectDefinitions;
     // Skeleton Animations
     TArray<FPaperSkeletonAnimationData> Animations;
     FPaperSkeletonAnimationData FindAnimation(FName animationName);

Should i keep them as UStructs or UObjects instead?

Keeping a pointer to a Higher-Level Data Object that owns the above Data Object is another necessity i cant seem to pull off right now. (See above code struct FPaperSkeletonAnimationData* AnimationOwner;)

I want to be able to pass around my Data Objects as pointers or references to make sure all other classes that access them, are accessing the most recent/updated version of them in the UPaperSkeletonData asset class.

Product Version: Not Selected
more ▼

asked Dec 03 '14 at 11:12 AM in C++ Programming

avatar image

100 14 18 25

avatar image Mercurial Forge Jan 23 '15 at 10:02 AM

I would love to know the answer to this as well. Getting data from Data Tables is great but being unable to pass it around as a pointer via struct at runtime is a big problem when you have things like equipment that needs to point to an inventory.

My assumption would be to store the Structs in a UObject Wrapper. Then point to the wrapper and edit as needed?

Simple Example:

 TArray<UArmorWrapper> Armors;
 //Character's Equipment
 UArmorWrapper* EquippedArmor;
 EquippedArmor->FArmorData.Degradation ++;
(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Hey Diddykonga and Oliver-

It is possible to have a pointer to a struct however it cannot be declared as a UPROPERTY which means it will only be available inside the code and cannot be used in the editor. Using Diddykong's structs as an example, removing the UPROPERTY() from line 9 and uncommenting line 10 should allow the code to compile successfully.


Doug Wilson

more ▼

answered Jan 05 '16 at 05:05 PM

avatar image Asusralis Apr 21 '16 at 03:57 AM

If I needed to use structure pointers, and I also need replication and to expose on spawn, how would I do that?

I'm make an inventory system with inherited structures. Because of this, I can't pass structures by value to the array that would hold the items. Do you know a good workaround for this?

avatar image Doug E ♦♦ STAFF Apr 22 '16 at 03:00 PM

Hey Asusralis-

Something you can try would be to create a class based on Data Asset. If you create your struct inside the data asset class you can define the defaults of your inventory in the struct, then you can create a pointer variable marked as UPROPERTY with replication to access / use the data asset struct elements.

(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