How to: use a for loop to create multiple instances of the same class type?

I am currently working with a customMesh, I currently have the class ATerrainMesh();, with child class TerrainFace(in,in,in,bool);. I wish to loop through a for loop to create each of the 20 TerrainFaces seperately.

Here is my relevant code that of how I would like to make initiate the 20 faces:

TArray<TerrainFace> terrainFaces;
	for (int i = 0; i < 20; i++)
	{
		int caseVar = i % 4;
		switch(caseVar)
		{
		case 0:
			triangleIndex1 = i + 3;
			triangleIndex2 = i;
			triangleIndex3 = i + 4;
			flipped = false;
		case 1:
			triangleIndex1 = i;
			triangleIndex2 = i + 3;
			triangleIndex3 = i - 1;
			flipped = true;
		case 2:
			triangleIndex1 = i + 2;
			triangleIndex2 = i - 1;
			triangleIndex3 = i + 3;
			flipped = false;
		case 3:
			triangleIndex1 = i - 1;
			triangleIndex2 = i + 2;
			triangleIndex3 = i - 2;
			flipped = true;
		}
		terrainFaces.Add(TerrainFace(triangleIndex1, triangleIndex2, triangleIndex3, flipped));
	}

Does anyone know how to properly define/call constructor of the terrainFace[i]?

I might have fixed my own problem by editing my own post as it seems to not display an error anymore. :smiley:

Now I just need to figure out how to get these TerrainFaces on the screen as 20 Actors with the TerrainMesh as their transform parent.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.