Maybe I’m just completely missing the point here and there’s a better way to do this. I’m trying to get a pretty simple dynamically sized 2D array of custom types. This is so close, but the response is not dynamic and I haven’t really found anything else that gets at this specific problem. In normal C++ I’d do something like
vector<vector<myClass>> myVect;
and that would allow me to do what I want. My searching indicates that TArray
is the most similar to a vector
but I keep getting errors when I try to do something like this:
TArray<TArray<myClass>> myArray;
Since this isn’t working, is there a “best practice” in Unreal that I’m not familiar with, or is there something else I’m missing? I also find it weird that Visual Studio isn’t giving me any red squigglies, it’s only when I compile that I’m made aware of the problem.
In case it helps, this is the actual error log:
CompilerResultsLog:Error: Error d:\program files\epic games\4.14\engine\source\runtime\core\public\Containers/Array.h(1745) : error C2248: 'ATile::ATile': cannot access private member declared in class 'ATile'
CompilerResultsLog:Error: Error c:\users\user\documents\unreal projects\sneakysnake\source\sneakysnake\public\Tile.h(11) : note: see declaration of 'ATile::ATile'
CompilerResultsLog:Error: Error c:\users\user\documents\unreal projects\sneakysnake\source\sneakysnake\public\Tile.h(9) : note: see declaration of 'ATile'
CompilerResultsLog:Error: Error d:\program files\epic games\4.14\engine\source\runtime\core\public\Containers/Array.h(1771) : note: see reference to function template instantiation 'int32 TArray<ATile,FDefaultAllocator>::Emplace<ATile>(ATile &&)' being compiled
CompilerResultsLog:Error: Error d:\program files\epic games\4.14\engine\source\runtime\core\public\Containers/Array.h(1771) : note: see reference to function template instantiation 'int32 TArray<ATile,FDefaultAllocator>::Emplace<ATile>(ATile &&)' being compiled
CompilerResultsLog:Error: Error d:\program files\epic games\4.14\engine\source\runtime\core\public\Containers/Array.h(1771) : note: while compiling class template member function 'int32 TArray<ATile,FDefaultAllocator>::Add(ATile &&)'
CompilerResultsLog:Error: Error C:\Users\user\Documents\Unreal Projects\SneakySnake\Source\SneakySnake\Private\WorldGen.cpp(24) : note: see reference to function template instantiation 'int32 TArray<ATile,FDefaultAllocator>::Add(ATile &&)' being compiled
CompilerResultsLog:Error: Error C:\Users\user\Documents\Unreal Projects\SneakySnake\Source\SneakySnake\Private\WorldGen.cpp(21) : note: see reference to class template instantiation 'TArray<ATile,FDefaultAllocator>' being compiled
all the rest of the codz can be found here.
tl;dr: I want a dynamic 2d array and TArray
is giving me lots of errors. What’s the correct way to do this?