Download

When using

This is the tutorial I followed

Hey so I’m trying to replicate what’s done in this tutorial in C++ only but I keep getting these errors when trying to use the getter function does any one know way

Code of primary asset
.h

UENUM(BlueprintType)
enum class EDataTable : uint8 {
	None,
	DT_1,
	DT_2,
	DT_3
};

UCLASS()
class UNREALCOC_API UTestPrimaryDataAsset : public UPrimaryDataAsset
{
	GENERATED_BODY()

public:
	UPROPERTY(EditAnywhere, Category = "DataTables")
	TMap<EDataTable, TSoftObjectPtr<UDataTable>> AvailableDataTables;
	
protected:
	UPROPERTY(EditAnywhere, Category = "Async Helper Data")
	TArray<EDataTable> DataTablesToFind;

#pragma region FUNCTIONS

	UFUNCTION(BlueprintCallable, Category = "Data Async Load Helper")
	void RequestAsyncLoad_DT(const UObject* DataOwner);

	UFUNCTION(BlueprintCallable, Category = "Data Async Load Helper")
	void UnloadAllObjects(const UObject* DataOwner);

	UFUNCTION(BlueprintCallable, Category = "Data Async Getter")
	TArray<UDataTable*> GetAvailableDataTables() const;

	UFUNCTION()
	void OnDataTableLoaded();

#pragma endregion

private:
	TArray<UDataTable*> FoundDataTables;
	TArray<FSoftObjectPath> ObjectsToUnload;
};

.cpp
TArray<UDataTable*> UTestPrimaryDataAsset::GetAvailableDataTables() const{
return FoundDataTables;
}

In DT_Ref
.h

class UNREALCOC_API UDT_Ref_Class : public UActorComponent
{
	GENERATED_BODY()

public:
    void TryLoad();
    UTestPrimaryDataAsset* TAsset = LoadObject<UTestPrimaryDataAsset>(NULL, TEXT("/Game/PrimaryAssets/TestDataTables2/TestDT_Asset"), NULL, LOAD_None, NULL);
    TArray<UDataTable*> Array;
}

.cpp

void UDT_Ref_Class::TryLoad(){
    if(TAsset != nullptr){
        //TAsset->execRequestAsyncLoad_DT(ContextO);
    }
    Array = TAsset->execGetAvailableDataTables();
}

when I do this I get these errors from my IDE
no operator “=” matches these operands
too few arguments in function call

i’ve also tried this
.cpp

void UDT_Ref_Class::TryLoad(){
    if(TAsset != nullptr){
        //TAsset->execRequestAsyncLoad_DT(ContextO);
    }
    TArray<UDataTable*>TestMe = TAsset->execGetAvailableDataTables();
}

when I do this I get these errors from my IDE
no suitable constructor exists to convert from “void” to “TArray<UDataTable*, FDefaultAllocator>”
too few arguments in function call

if any one can help with these errors it would be appreciated

When working in C++, you don’t call the exec functions. Just call GetAvailableDataTables. The exec functions are generated for supporting Blueprint since you made the function BlueprintCallable.

Also, I’m pretty sure that initialization for TAsset isn’t legal. You’d have to make that call from the constructor or from within a function somewhere.

No real idea. But I don’t follow many internet information when learning about something as complicated as computer programming. I recommend you find a good and current book about C++ game programing and good and current book on C++ computer programming language. Maybe a good and current book in C++ computer programming too. A good book can be far more helpful than an internet tutorial. A tutorial on the internet may not list everything you need to run the program properly. But a book would tell you much more about what you might need. Look up books on Amazon kindle, Google Play Books, and Google Books. They have a lot of ebooks. But buying a regular paper book would not hurt either. Amazon and Google Books have paperback and Hardback books. Walmart sometimes has them too. Thrift books, Barn and Noble, Discovery Books, and the Good Will store have good book buying options too. Look at books for video game designers too. That can be very helpful. And look at game engines like Unity and Unreal Engine. Blender is also a good engine if you can get it to run on your computer or laptop. Game engines are really helpful in building your own games. To learn more about game engines you can try online. But I would recommend you look at a good book about game developing and how to be a game developer. Many games are programmed in C++ and many game developers use C++. Learning about game development and game developers would be a huge help to you I think. As well as a good book on C++ programming language and programming games in C++. A book would teach you far more than a tutorial or I could. Good luck with your game :+1:

Well, Cam9001 is kind of right. You are posting C++ compilation errors. Maybe this isn’t the right place for this questions.

Ok so I think I figured out my problem it turns out I was using the exec version of the function which was causing the bulk of the problem

1 Like