# How to create a UStruct from scratch

**URL:** <https://forums.unrealengine.com/t/how-to-create-a-ustruct-from-scratch/50672>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [December 23, 2015, 6:40am UTC](https://forums.unrealengine.com/t/how-to-create-a-ustruct-from-scratch/50672 "2015-12-23T06:40:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![evehal](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@evehal](https://forums.unrealengine.com/u/evehal)\
**Post date:** [December 23, 2015, 6:40am UTC](https://forums.unrealengine.com/t/how-to-create-a-ustruct-from-scratch/50672/1 "2015-12-23T06:40:05Z")

</div>

here is the link for USTRUCT creation.

> **[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 — ue4community.wiki! You will be able to find content from the official...

but it works when i put the USTRUCT in a generated head file only.  
for example:

#include “Class.h”  
USTRUCT(BlueprintType)  
struct FCraftBy  
{  
GENERATED\_USTRUCT\_BODY()  
};

if i put FCraftBy in a head file that created by myself, then i got compiler errors.

---

<div class="post-metadata">

**Author:** ![maybe\_ilya](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@maybe\_ilya](https://forums.unrealengine.com/u/maybe_ilya)\
**Post date:** [December 23, 2015, 11:32am UTC](https://forums.unrealengine.com/t/how-to-create-a-ustruct-from-scratch/50672/2 "2015-12-23T11:32:45Z")

</div>

Catch simple struct example. Hope it helps you

LessonOct21Struct.h

```auto

#pragma once
#include "LessonOct21Struct.generated.h"

USTRUCT(BlueprintType)
struct FLessonOct21Struct
{
	GENERATED_USTRUCT_BODY()
public:
	FLessonOct21Struct();
	FLessonOct21Struct(float x, float y, float z);

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Test Struct")
		float MyX;
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Test Struct")
		float MyY;
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Test Struct")
		float MyZ;
	static FLessonOct21Struct Add(FLessonOct21Struct A, FLessonOct21Struct B);
};

```

LessonOct21Struct.cpp

```auto

#include "DML_UE4_Course.h"
#include "LessonOct21Struct.h"

FLessonOct21Struct::FLessonOct21Struct()
{
	MyX = 0.0f;
	MyY = 0.0f;
	MyZ = 0.0f;
}
FLessonOct21Struct::FLessonOct21Struct(float x, float y, float z)
{
	MyX = x;
	MyY = y;
	MyZ = z;
}

FLessonOct21Struct FLessonOct21Struct::Add(FLessonOct21Struct A, FLessonOct21Struct B)
{
	return FLessonOct21Struct(A.MyX + B.MyX, A.MyY + B.MyY, A.MyZ + B.MyZ);
}

```
