Is it possible to set an array of templates for my blueprint, for the sake of convenience?

So I recently got my code to compile when I had a single blueprint template for the fences I wanted to spawn from my spawner object blueprint. Now, I’m trying to expand that into a set of multiple possible templates. The idea is that when I want to spawn a fence, I can choose from one of eight different templates (representing fences of different heights) whether at random or by some other logic. Really, the only difference between the fence blueprints is their static meshes.

At present, my code looks like this:
ObstacleSpawner.h

//Create a template to allow for multiple blueprints of fence objects to track
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Fence")
	TSubclassOf<class AFenceObstacle> FenceTemplate[8];

ObstacleSpawner.cpp (Tick)

//Increment/Decrement timers, spawn objects
if (SpawnTimer <= 0.0f) {
	//Spawn a new fence obstacle with appropriate height
	int FenceHeight = FMath::RandRange(0, 7);
        if (FenceTemplate[FenceHeight]) {
		AFenceObstacle* NewFence = World->SpawnActor<AFenceObstacle>(FenceTemplate[FenceHeight]);
		FVector SpawnLocation = FVector(1000.0f, 0.0f, 0.0f);
		NewFence->SetActorLocation(SpawnLocation);
		NewFence->ObstacleSpeed = ObstacleSpeed;

		Fences.Add(NewFence);
	} else {
		//DEBUG
		GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Red, "Spawning new fence FAILED because FenceTemplate is not defined.");
	}

	SpawnTimer = 5.0f;	//<-- This will be modified later to depend on TimeElapsed
}

When I try to compile, I get this error message in my Output tab:

Error: Static array cannot be exposed to blueprint ObstacleSpawner.FenceTemplate

Suggestions?

I use a TArray<UClass*> for the items to be spawned in a similar application. I don’t think a static C++ array can be Blueprintable in the UPROPERTY statement, a TArray can. Strikes me some form of TArray will be the solution.

Okay. I tried using the TArray declaration instead, as shown here in my ObstacleSpawner.h file:
image

And in this section of my ObstacleSpawner.cpp file:

I get the following errors, apparently related to the SpawnActor method:

This is probably me confusing instances for pointers again, but if anything looks familiar to you, please let me know.

You’re giving the wrong arguments to UWorld::SpawnActor - look at the method signature, or at the docs. It doesn’t take an actor pointer. The error is telling you that there’s no version of the function which takes the argument list you’ve given it.

Here are the different versions of that function: SpawnActor | Unreal Engine Documentation

You probably want TArray<TSubclassOf<AFenceObstacle>> as your property. TSubclassOf is a UClass* with some useful features - it only lets you set it to subclasses of the template argument, so only to AFenceObstacle-derived classes here. The rest of your code should work unmodified once you make that change.

Thank you for clarifying how that TArray should work. I often get confused when multiple sets of brackets are involved with stuff like this.