Hi guys. I am new to Unreal Engine and struggling with accessing to my DataAssets in C++.
I made a simple game that Player has to pick up items which are spawned per 2-5 seconds, to recover his health. After completing that, I thought I better add some more items not just simgle, like speed-up item, more recovery item, etc. And so I made C++ class named SpawnableItem_DataAsset which derives from UDataAsset, and actual instances from the data assets (Are they blueprints? I made them by right clicking mouse and selecting Miscellaneous > DataAsset > SpawnableItem_DataAsset in Content browser), which now stores data for an item, such as its actor, its spawn rate, and so on. Then, I added an SpawnableItem_DataAsset array variable to my actor blueprint to spawn items, and made nodes to select one of them and spawn it. It worked! But the event graph is messed up, so I decided to translate nodes in the event graph to C++.
So, first, in my C++ class to spawn items, I added these as below.
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (MustImplement = SpawnableItemInterface)) TArray<TSubclassOf<USpawnableItem_DataAsset>> SpawnableItems; UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (MustImplement = SpawnableItemInterface)) TArray<USpawnableItem_DataAsset*> SpawnableItems2;
But none of those worked. No compile error, but I cannot get my data assets with them.
With TArray<USpawnableItem_DataAsset*>, I can select my defined data asset from the editor, but when I select it, the value is still None.
Is anyone knows how to solve this? Thanks.