Hello everyone. So I have two C++ actor classes called TetrisGridPiece and TetrisGrid. Within TetrisGrid I wanted to create an array that is composed of instances of the TetrisGridPiece class but I don’t know how to do so. Does anyone know how to create an array of C++ classes and populate it?
Unless there’s a certain method I don’t know about, that’s something I did in Blueprints, which worked. But I want it to be done in C++. Do you have an example in code?
Create array varable of TetrisGridPiece pointers:
And… thats it array is ready to go now you can use Add() or AddUnique() functions to place actor pointers, you can do that toghther with spawning if you wish:
Here you got list of TArray functions:
Also not that TArray is not a pointer (but you can create pointer to array if you wish) so you use “.” insted of “->” to call functions
Edit: you know spawning and adding in same time might not be smartest idea… so treat it as a example
Hmm whenever I try to put in TArray ArrayName; I get an error, specifically on the . Here’s the error:
Unrecognized type 'TetrisGridPiece'
Should it be ATetrisGridPiece*?
Likely yes. If your grid piece is an actor then it has to be prefixed with an A I believe.
oops, i thought you were asking how to create a c++ class in blueprint.
Well obviuesly, think by yourself a little ;p besides you the one who said class name TetrisGridPiece
I was just making sure LOL. I’m not that great at UE4. Anyways thanks.