# Spawning Blueprint class from random pool defined in editor

**URL:** <https://forums.unrealengine.com/t/spawning-blueprint-class-from-random-pool-defined-in-editor/355516>\
**Category:** Blueprint\
**Tags:** tarray, unreal-engine, Blueprint, CPP, question, pointers\
**Created:** [April 26, 2016, 9:53am UTC](https://forums.unrealengine.com/t/spawning-blueprint-class-from-random-pool-defined-in-editor/355516 "2016-04-26T09:53:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![NikDouglas](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@NikDouglas](https://forums.unrealengine.com/u/NikDouglas)\
**Post date:** [April 26, 2016, 9:53am UTC](https://forums.unrealengine.com/t/spawning-blueprint-class-from-random-pool-defined-in-editor/355516/1 "2016-04-26T09:53:19Z")

</div>

Hi all,

I’m trying to create a class that can randomly spawn a Blueprint class from a pool defined through a TArray in the editor. For this I have two classes: A Section class and a SectionScene class. In the Section class, you are able to add several SectionScene classes to an array in the editor. I have achieved this in the .h using:

```
//Create a pool of Section Scenes to choose randomly from
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Section Scenes")
TArray<TSubclassOf<class ATBSectionScene>> ArrSectionScenePool;

//The Section scene to use
TSubclassOf<class ATBSectionScene> SectionScene;

```

Then in the .cpp constructor I am trying to assign a randomly chosen Section Scene from the ArrSectionScenePool array to the SectionScene variable:

```
//If there are some section scenes defined in the section scene pool
if (ArrSectionScenePool.Num)
{
	//choose a random scene from the pool and assign it as *the* scene
	int sceneIndex = (int)FMath::Floor(FMath::RandRange(0, ArrSectionScenePool.Num));
	SectionScene = ArrSectionScenePool[sceneIndex];
}

```

I now get the following error:  
…TBSection.cpp(14): error C3867: ‘TArray,FDefaultAllocator\>::Num’: non-standard syntax; use ‘&’ to create a pointer to member

I come from a Unity/C# background and honestly don’t really have any idea what this means. I tried converting the TArray into a pointer but apparently this is not allowed in UE4.

Am I doing this completely wrong? Is there a best practice way to achieve this?

Thanks in advance :).

---

<div class="post-metadata">

**Author:** ![NikDouglas](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@NikDouglas](https://forums.unrealengine.com/u/NikDouglas)\
**Post date:** [April 26, 2016, 10:27am UTC](https://forums.unrealengine.com/t/spawning-blueprint-class-from-random-pool-defined-in-editor/355516/2 "2016-04-26T10:27:31Z")

</div>

Sorry, I made a noob mistake and omitted the () from .Num - also, I can’t put this in the constructor obviously so I moved it to BeginPlay().

Thanks anyway 🙂
