Don't know what's error here?

Hello there, greetings of the day, I am working on a FPS game by watching some tutorials on YouTube, but I am getting error while compiling the code, I guess the error is in Onyx.h file, I am very new to Unreal Engine and just learning how to code for Unreal Engine. Can somebody help me with this?

Here is the code

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Character.h"
#include "GameFramework/SpringArmComponent.h"
#include "Onyx.generated.h"
#include <Camera/CameraComponent.h>

UCLASS()
class MYBG_API AOnyx : public ACharacter
{
	GENERATED_BODY()

public:
	// Sets default values for this character's properties
	AOnyx();

protected:
	// Called when the game starts or when spawned
	virtual void BeginPlay() override;

public:	
	// Called every frame
	virtual void Tick(float DeltaTime) override;

	// Called to bind functionality to input
	virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;

	//Public Variables
	//Define Input key for MoveForwardKey
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "BR Variables")
	FString MoveForwardKey;
	//Define Input key for MoveRight
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "BR Variables")
	FString MoveRightKey;
	//Define Input key for Turn
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "BR Variables")
	FString TurnKey;
	//Define Input key for LookUp
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "BR Variables")
	FString LookUpKey;
	//Define Input key for Sprint
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "BR Variables")
	FString SprintKey;

	//Max Walk Speed
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "BR Variables")
	float MaxWalkSpeed;
	//Max Sprint Speed
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "BR Variables")
	float MaxSprintSpeed;

protected:
	void MoveForward(float AxisVal);
	void MoveRight(float AxisVal);
	void LookUp(float AxisVal);
	void Turn(float AxisVal);
	void Jump();
	void Sprint();

	UPROPERTY(BlueprintReadOnly, VisibleAnywhere, meta = (AllowPrivateAccess = true))
	bool bPlayerIsSprinting;

	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Components")
	USpringArmComponent* SpringArmComponent;

	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Components")
	UCameraComponent* CameraComponent;

};

And here is the error

Build started...
1>------ Build started: Project: MyBG, Configuration: DebugGame_Editor x64 ------
1>Running UnrealBuildTool: dotnet "..\..\Engine\Binaries\DotNET\UnrealBuildTool\UnrealBuildTool.dll" MyBGEditor Win64 DebugGame -Project="C:\Users\Ranju\Documents\Unreal Projects\MyBG\MyBG.uproject" -WaitMutex -FromMsBuild
1>Log file: C:\Users\Ranju\AppData\Local\UnrealBuildTool\Log.txt
1>Invalidating makefile for MyBGEditor (working set of source files changed)
1>Parsing headers for MyBGEditor
1>  Running Internal UnrealHeaderTool "C:\Users\Ranju\Documents\Unreal Projects\MyBG\MyBG.uproject" "C:\Users\Ranju\Documents\Unreal Projects\MyBG\Intermediate\Build\Win64\MyBGEditor\DebugGame\MyBGEditor.uhtmanifest" -WarningsAsErrors -installed
1>Total of 0 written
1>Reflection code generated for MyBGEditor in 1.2289364 seconds
1>Building MyBGEditor...
1>Using Visual Studio 2022 14.33.31631 toolchain (C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629) and Windows 10.0.22621.0 SDK (C:\Program Files (x86)\Windows Kits\10).
1>Determining max actions to execute in parallel (8 physical cores, 16 logical cores)
1>  Executing up to 8 processes, one per physical core
1>  Requested 1.5 GB free memory per action, 4.76 GB available: limiting max parallel actions to 3
1>Building 7 actions with 3 processes...
1>[1/7] Compile Onyx.gen.cpp
1>C:\Users\Ranju\Documents\Unreal Projects\MyBG\Source\MyBG\Onyx.h(12): error C2143: syntax error: missing ';' before '<class-head>'
1>C:\Users\Ranju\Documents\Unreal Projects\MyBG\Source\MyBG\Onyx.h(12): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Users\Ranju\Documents\Unreal Projects\MyBG\Source\MyBG\Onyx.h(14): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Users\Ranju\Documents\Unreal Projects\MyBG\Intermediate\Build\Win64\UnrealEditor\Inc\MyBG\UHT\Onyx.gen.cpp(19): error C2039: 'StaticRegisterNativesAOnyx': is not a member of 'AOnyx'
1>C:\Users\Ranju\Documents\Unreal Projects\MyBG\Source\MyBG\Onyx.h(12): note: see declaration of 'AOnyx'
1>C:\Users\Ranju\Documents\Unreal Projects\MyBG\Intermediate\Build\Win64\UnrealEditor\Inc\MyBG\UHT\Onyx.gen.cpp(22): error C2509: 'GetPrivateStaticClass': member function not declared in 'AOnyx'
1>C:\Users\Ranju\Documents\Unreal Projects\MyBG\Source\MyBG\Onyx.h(12): note: see declaration of 'AOnyx'
1>C:\Users\Ranju\Documents\Unreal Projects\MyBG\Intermediate\Build\Win64\UnrealEditor\Inc\MyBG\UHT\Onyx.gen.cpp(161): error C2248: 'AOnyx::bPlayerIsSprinting': cannot access protected member declared in class 'AOnyx'
1>C:\Users\Ranju\Documents\Unreal Projects\MyBG\Source\MyBG\Onyx.h(64): note: see declaration of 'AOnyx::bPlayerIsSprinting'
1>C:\Users\Ranju\Documents\Unreal Projects\MyBG\Source\MyBG\Onyx.h(12): note: see declaration of 'AOnyx'
1>C:\Users\Ranju\Documents\Unreal Projects\MyBG\Intermediate\Build\Win64\UnrealEditor\Inc\MyBG\UHT\Onyx.gen.cpp(171): error C2248: 'AOnyx::SpringArmComponent': cannot access protected member declared in class 'AOnyx'
1>C:\Users\Ranju\Documents\Unreal Projects\MyBG\Source\MyBG\Onyx.h(67): note: see declaration of 'AOnyx::SpringArmComponent'
1>C:\Users\Ranju\Documents\Unreal Projects\MyBG\Source\MyBG\Onyx.h(12): note: see declaration of 'AOnyx'
1>C:\Users\Ranju\Documents\Unreal Projects\MyBG\Intermediate\Build\Win64\UnrealEditor\Inc\MyBG\UHT\Onyx.gen.cpp(179): error C2248: 'AOnyx::CameraComponent': cannot access protected member declared in class 'AOnyx'
1>C:\Users\Ranju\Documents\Unreal Projects\MyBG\Source\MyBG\Onyx.h(70): note: see declaration of 'AOnyx::CameraComponent'
1>C:\Users\Ranju\Documents\Unreal Projects\MyBG\Source\MyBG\Onyx.h(12): note: see declaration of 'AOnyx'
1>C:\Users\Ranju\Documents\Unreal Projects\MyBG\Intermediate\Build\Win64\UnrealEditor\Inc\MyBG\UHT\Onyx.gen.cpp(222): error C2511: 'AOnyx::AOnyx(FVTableHelper &)': overloaded member function not found in 'AOnyx'
1>C:\Users\Ranju\Documents\Unreal Projects\MyBG\Source\MyBG\Onyx.h(12): note: see declaration of 'AOnyx'
1>C:\Users\Ranju\Documents\Unreal Projects\MyBG\Intermediate\Build\Win64\UnrealEditor\Inc\MyBG\UHT\Onyx.gen.cpp(222): error C2550: 'AOnyx::{ctor}': constructor initializer lists are only allowed on constructor definitions
1>C:\Users\Ranju\Documents\Unreal Projects\MyBG\Intermediate\Build\Win64\UnrealEditor\Inc\MyBG\UHT\Onyx.gen.cpp(223): error C2600: 'AOnyx::~AOnyx': cannot define a compiler-generated special member function (must be declared in the class first)
1>[2/7] Compile OnyxAnimInstance.gen.cpp
1>C:\Users\Ranju\Documents\Unreal Projects\MyBG\Source\MyBG\Onyx.h(12): error C2143: syntax error: missing ';' before '<class-head>'
1>C:\Users\Ranju\Documents\Unreal Projects\MyBG\Source\MyBG\Onyx.h(12): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Users\Ranju\Documents\Unreal Projects\MyBG\Source\MyBG\Onyx.h(14): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>[3/7] Compile OnyxAnimInstance.cpp
1>C:\Users\Ranju\Documents\Unreal Projects\MyBG\Source\MyBG\Onyx.h(12): error C2143: syntax error: missing ';' before '<class-head>'
1>C:\Users\Ranju\Documents\Unreal Projects\MyBG\Source\MyBG\Onyx.h(12): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Users\Ranju\Documents\Unreal Projects\MyBG\Source\MyBG\Onyx.h(14): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>[4/7] Compile Onyx.cpp
1>C:\Users\Ranju\Documents\Unreal Projects\MyBG\Source\MyBG\Onyx.h(12): error C2143: syntax error: missing ';' before '<class-head>'
1>C:\Users\Ranju\Documents\Unreal Projects\MyBG\Source\MyBG\Onyx.h(12): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Users\Ranju\Documents\Unreal Projects\MyBG\Source\MyBG\Onyx.h(14): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>[5/7] Link UnrealEditor-MyBG-Win64-DebugGame.dll cancelled
1>[6/7] Link UnrealEditor-MyBG-Win64-DebugGame.lib cancelled
1>[7/7] WriteMetadata MyBGEditor-Win64-DebugGame.target cancelled
1>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.MakeFile.Targets(44,5): error MSB3073: The command "D:\UE_5.1\Engine\Build\BatchFiles\Build.bat MyBGEditor Win64 DebugGame -Project="C:\Users\Ranju\Documents\Unreal Projects\MyBG\MyBG.uproject" -WaitMutex -FromMsBuild" exited with code 6.
1>Done building project "MyBG.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Build started at 2:39 PM and took 11.126 seconds ==========

Please help me.

You need to move #include “Onyx.generated.h” to be the last in the list of includes. You cannot put any other include below it.

Oh, I did not know even that affects the compilation. Thank You very much for the help.

Can you please tell me where did you learn to code for Unreal Engine and what courses I can take to learn?

I’ve been coding for over 20 years in many languages.
Unreal is just c++ with extra macros, classes and custom libraries.
I mostly just use the documentation.

But there are a couple of YouTube channels that can show you the basics

Reubs has some simple to follow tutorials

1 Like

Okay, thank you very much for the help.