This is Maze.h, the header file containing the structs. (I assume this is what you mean by “the header file for the structs”)
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "GameFramework/Actor.h"
#include "Maze.generated.h"
UCLASS()
class MAZEGAME_API AMaze : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
AMaze();
// Called when the game starts or when spawned
virtual void BeginPlay() override;
// Called every frame
virtual void Tick( float DeltaSeconds ) override;
AMaze(int height, int width);
USTRUCT(BlueprintType)
struct MAZEGAME_API FMazeRow
{
GENERATED_USTRUCT_BODY()
//or could be using a simple data type instead of a Data Unit Struct
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Maze Array")
TArray<bool> col;
FMazeRow(){}
};
USTRUCT(BlueprintType)
struct MAZEGAME_API FMazeArray
{
GENERATED_USTRUCT_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Maze Array")
TArray<FMazeRow> row;
FMazeArray(){}
};
};
Here is the MazeGame.cpp (I haven’t touched this at all, I added the class to what is originally a blueprint third-person default game)
// Fill out your copyright notice in the Description page of Project Settings.
#include "MazeGame.h"
IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, MazeGame, "MazeGame" );
I don’t use either of the structs anywhere yet, I haven’t written any code yet really because making the 2D array was the first thing I tried to do.
I tried adding Include “MazeGame.generated.h” to the MazeGame.h since that wasn’t in there but it says it doesn’t exist, and since I didn’t make this file I would assume Unreal made the file correctly to start with.
Just for the fun of it:
MazeGame.h
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "Engine.h"
Maze.cpp
// Fill out your copyright notice in the Description page of Project Settings.
#include "MazeGame.h"
#include "Maze.h"
// Sets default values
AMaze::AMaze()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = false;
}
AMaze::AMaze(int height, int width)
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = false;
}
// Called when the game starts or when spawned
void AMaze::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void AMaze::Tick( float DeltaTime )
{
Super::Tick( DeltaTime );
}