First the question: how to “SpawnActor” a inherited class with constructor parameters?
Following a explanation of what I have tried:
So I made a inherited class/Actor of my TerrainMesh Actor. My goal was to have my “main actor” function as the general coordinates for my terrain. under my main actor I wanted to create 20 sub class objects which each render a single face of the mesh. Now here is the problem, my sub classes are procedural meshes, which require an input argument to calculate the locations of the vertices in the BeginPlay().
So, does anyone know how to do this? I read something about placing SpawnActorProperties after the transform arguments. But I haven’t found a single good example. I did see some good blueprint examples online. However, I prefer to do it in C++ if possible.
Here is a simplified version of my inherited actor with the corresponding constructor arguments.
UCLASS()
class GAMENAME_API ATerrainFace : public ATerrainMesh
{
GENERATED_BODY()
public:
ATerrainFace(int index1, int index2, int index3, bool flip)
{
SetPosition(index1, index2, index3, flip);
}
void SetPosition(int, int, int, bool);
void SetTriangles();
void GenerateMesh();
};
And here is how I expect the spawnActor to more or less look like:
GetWorld()->SpawnActor<AActor>(TerrainToSpawn, Location, Rotation, ?????????);