# Need help finishing up my Advanced Wave Spawning System.

**URL:** <https://forums.unrealengine.com/t/need-help-finishing-up-my-advanced-wave-spawning-system/55832>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [February 18, 2016, 9:25pm UTC](https://forums.unrealengine.com/t/need-help-finishing-up-my-advanced-wave-spawning-system/55832 "2016-02-18T21:25:43Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![anonymous\_user\_5b5c8515](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_5b5c8515](https://forums.unrealengine.com/u/anonymous_user_5b5c8515)\
**Post date:** [February 19, 2016, 2:13am UTC](https://forums.unrealengine.com/t/need-help-finishing-up-my-advanced-wave-spawning-system/55832/2 "2016-02-19T02:13:59Z")

</div>

I always try to code in a way that is designer friendly, even if I’m working on my own. It seems you would be better served by using a DataTable. You can create and edit these in editor or export/import data to .csv and .json.  
DataTables are built from a struct, make sure your struct is properly exposed to the editor.

Everything you need to know about referencing a DataTable in C++ and accessing its rows can be found in these links:

> **[Driving Gameplay with Data from Excel](https://forums.unrealengine.com/showthread.php?12572-Driving-Gameplay-with-Data-from-Excel)**
>
> Ask any game programmer, and they’ll tell you that it’s best to adopt a data-driven approach that allows game designers to tweak as much about the gameplay as possible without the aid of a programmer. If you talk to the game designers themselves,...

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — https://unrealcommunity.wiki/! You will be able to find content from...

You dont actually need Excel to work with data tables anymore, those links are a little old. In the content browser RightClick-\>Miscellaneous-\>DataTable to create a new table. A popup asks you for a struct to base the table on, just give it your FWaveData struct and you can start adding rows for each wave.

Here’s an example of how I would approach it. I havn’t compiled any of this, just copy/pasted from a few sources and tweaked, but it should give you an idea of how to set it up.

In .h

```auto

USTRUCT(BlueprintType)
struct FWaveData
{
	GENERATED_USTRUCT_BODY()

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
		int32 MaxSpawnsPerWave;

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
		int32 MaxSpawnsAtATime;

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
		TArray<int32> SpawnPriorities;

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
		TArray<TSubclassOf<AEnemy_Base>> EnemyTypes;
};

UPROPERTY(BlueprintReadOnly)
UDataTable* WaveDataTable;

UPROPERTY(EditAnywhere, BlueprintReadWrite)
FWaveData CurrentWaveData;

```

In .cpp

```auto

AZombieSpawnTutorial::AZombieSpawnTutorial() //Find the editor asset in the constructor
{
        ConstructorHelpers::FObjectFinder<UDataTable> WaveDataTable_BP(TEXT("DataTable'/Game/DataTables/ExcelExample.ExcelExample'"));

        WaveDataTable= WaveDataTable_BP.Object;
}

AZombieSpawnTutorial::IterateWave()
{
	CurrentWave++;

	FString WaveName = FString::FromInt(CurrentWave);

	CurrentWaveData = WaveDataTable->FindRow<FWaveData>(FText::FromString(WaveName));

	OnBeginSpawnWave();
}

```

The resulting DataTable in editor. Super easy to edit!

 ![Ne1UXzX.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/7/7/57730f0e6bc872875d49438d0271bb68244de55e.png)

---

_[View the full topic](https://forums.unrealengine.com/t/need-help-finishing-up-my-advanced-wave-spawning-system/55832)._
