Cant build struct in c++

I have the following:

// Copyright Epic Games, Inc. All Rights Reserved.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/GameModeBase.h"
#include "Escape_from_CaelumGameMode.generated.h"

//If you want this to appear in BP, make sure to use this instead //USTRUCT(BlueprintType)
USTRUCT() struct MapZone
{
    GENERATED_BODY()

        UPROPERTY()
        int32 SampleInt32;

    UPROPERTY()
        AActor* TargetActor;
};


UCLASS(minimalapi)
class AEscape_from_CaelumGameMode : public AGameModeBase
{
	GENERATED_BODY()

public:
	AEscape_from_CaelumGameMode();

	UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="EFC|Zones")
	TArray<MapZone> MapZones;
};

When i attempt to build it i get the following error:

Error: When compiling struct definition for ‘MapZone’, attempting to strip prefix results in an empty name. Did you leave off a prefix?

can anyone tell me what ive done wrong?

Try

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/GameModeBase.h"
#include "GameFramework/Actor.h" 
#include "Escape_from_CaelumGameMode.generated.h"


USTRUCT(BlueprintType)
struct FMapZone
{
    GENERATED_BODY()

    UPROPERTY()
        int32 SampleInt32;

    UPROPERTY()
        AActor* TargetActor;
};


UCLASS()
class AEscape_from_CaelumGameMode : public AGameModeBase
{
	GENERATED_BODY()
	

public:
    UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "EFC|Zones")
        TArray<FMapZone> MapZones;
};
2 Likes

Every struct in the Unreal reflection system must have a prefix of F so the C++ name of your type should be FMapZone

Just like actors need to have a prefix of A and other uobjects must have a prefix of U

Unreal Engine: It’s a way of life.

3 Likes