I'm trying to include my Header with helpful functions into my unreal project in order to be able to include it in many other .h classes generated from inside the Editor so that they all can access them, but I am getting a lot of Errors...
This is my .h file created from inside VS which I would like to use inside my project:
#pragma once
#include "Engine/World.h"
#include "Classes/Kismet/KismetSystemLibrary.h"
#include "WormGameMode.h"
#include "WormGameMode.generated.h"
//Given a position in the world, returns [row][column]ID inside the GridSlotsOccupiedMap grid.
//FVector(0.f,0.f,0.f) is the center inside the 2D Array, the 2DArray is expected to have and ODD number of elements.
UFUNCTION(BlueprintPure, Category = "Grid")
void WorldLocationToGridID(AWormGameMode* GameMode, FVector Location, int& Row, int&Column)
{
int RowMiddleID = (GameMode->GridHeight / GameMode->GridBlockSize) / 2;
int ColumnMiddleID = (GameMode->GridWidth / GameMode->GridBlockSize) / 2;
int GridBlockSize = GameMode->GridBlockSize;
//------------------------------------------
Row = -Location.Z / GridBlockSize + RowMiddleID;
Column = Location.X / GridBlockSize + ColumnMiddleID;
}
//Display red wireframe cubes at the occupied position in the grid marked inside GridSlotsOccupiedMap
UFUNCTION(BlueprintCallable, Category = "Debug")
void DebugMarkOccupiedBlocks(AWormGameMode* GameMode)
{
TArray<TArrayBool> GridSlotsOccupiedMap = GameMode->GetGridSlotsOccupiedMap();
int GridWidth = GameMode->GridWidth;
int GridHeight = GameMode->GridHeight;
int GridBlockSize = GameMode->GridBlockSize;
int XMiddleID = (GridWidth / GridBlockSize) / 2;
int YMiddleID = (GridHeight / GridBlockSize) / 2;
//-----------------------------------------------
for (int row = 0; row < GridSlotsOccupiedMap.Num(); row++)
{
for (int column = 0; column < GridSlotsOccupiedMap[0].BoolRow.Num(); column++)
{
float X = (-XMiddleID + column) * GridBlockSize;
float Z = (YMiddleID - row) * GridBlockSize;
FVector Center = FVector(X, 50.f, Z + GridBlockSize/2);
if (GridSlotsOccupiedMap[row][column])
{
UE_LOG(LogTemp, Warning, TEXT("Block[%i][%i] is occupied"), row, column)
UKismetSystemLibrary::DrawDebugBox(GetWorld(),
Center, FVector(5.7f, 5.7f, 5.7f),
FColor::Red, FRotator::ZeroRotator, 0.f, 0);
}
}
}
}
As you see I've included #include "WormGameMode.generated.h" as instruction from a topic I've found online, also I've Cut/Pasted it from the Intermediate/ProjectFiles folder where VS created it and pasted into Worm/Source/Worm folder.
Here's the errors the editor is giving back:
QuoteCompilerResultsLog: Error: z:\asus\documenti\unreal projects\worm\source\worm\WormHelperFunctions.h(10) : error C2065: 'AWormGameMode': identificatore non dichiarato
CompilerResultsLog: Error: z:\asus\documenti\unreal projects\worm\source\worm\WormHelperFunctions.h(10) : error C2065: 'GameMode': identificatore non dichiarato
CompilerResultsLog: Error: z:\asus\documenti\unreal projects\worm\source\worm\WormHelperFunctions.h(10) : error C2275: 'FVector': tipo non valido come espressione
CompilerResultsLog: Error: z:\asus\documenti\unreal projects\worm\intermediate\build\win64\ue4editor\inc\worm\WormGameMode.generated.h(11) : note: vedere la dichiarazione di 'FVector'
CompilerResultsLog: Error: z:\asus\documenti\unreal projects\worm\source\worm\WormHelperFunctions.h(10) : error C2065: 'AWormGameMode': identificatore non dichiarato
CompilerResultsLog: Error: z:\asus\documenti\unreal projects\worm\source\worm\WormHelperFunctions.h(10) : error C2065: 'GameMode': identificatore non dichiarato
CompilerResultsLog: Error: z:\asus\documenti\unreal projects\worm\source\worm\WormHelperFunctions.h(10) : error C2275: 'FVector': tipo non valido come espressione
CompilerResultsLog: Error: Z:\Asus\Documenti\Unreal Projects\Worm\Intermediate\Build\Win64\UE4Editor\Inc\Worm\WormGameMode.generated.h(11) : note: vedere la dichiarazione di 'FVector'
CompilerResultsLog: Error: z:\asus\documenti\unreal projects\worm\source\worm\WormHelperFunctions.h(10) : error C2146: errore di sintassi: ')' mancante prima dell'identificatore 'Location'z:\asus\documenti\unreal projects\worm\source\worm\WormHelperFunctions.h(10): error C2146: errore di sintassi: ')' mancante prima dell'identificatore 'Location'
CompilerResultsLog: Error: z:\asus\documenti\unreal projects\worm\source\worm\WormHelperFunctions.h(11) : error C2143: errore di sintassi: ';' mancante prima di '{'z:\asus\documenti\unreal projects\worm\source\worm\WormHelperFunctions.h(11): error C2143: errore di sintassi: ';' mancante prima di '{'
CompilerResultsLog: Error: z:\asus\documenti\unreal projects\worm\source\worm\WormHelperFunctions.h(11) : error C2447: '{': intestazione di funzione mancante. Elenco formale di tipo obsoleto?z:\asus\documenti\unreal projects\worm\source\worm\WormHelperFunctions.h(11): error C2447: '{': intestazione di funzione mancante. Elenco formale di tipo obsoleto?
CompilerResultsLog: Error: z:\asus\documenti\unreal projects\worm\source\worm\WormHelperFunctions.h(24) : error C2065: 'AWormGameMode': identificatore non dichiaratoz:\asus\documenti\unreal projects\worm\source\worm\WormHelperFunctions.h(24): error C2065: 'AWormGameMode': identificatore non dichiarato
CompilerResultsLog: Error: z:\asus\documenti\unreal projects\worm\source\worm\WormHelperFunctions.h(24) : error C2065: 'GameMode': identificatore non dichiaratoz:\asus\documenti\unreal projects\worm\source\worm\WormHelperFunctions.h(24): error C2065: 'GameMode': identificatore non dichiarato
CompilerResultsLog: Error: z:\asus\documenti\unreal projects\worm\source\worm\WormHelperFunctions.h(24) : error C2182: 'DebugMarkOccupiedBlocks': utilizzo non valido del tipo 'void'z:\asus\documenti\unreal projects\worm\source\worm\WormHelperFunctions.h(24): error C2182: 'DebugMarkOccupiedBlocks': utilizzo non valido del tipo 'void'
CompilerResultsLog: Error: z:\asus\documenti\unreal projects\worm\source\worm\WormHelperFunctions.h(25) : error C2448: 'DebugMarkOccupiedBlocks': l'inizializzatore di tipo funzione sembra essere una definizione di funzionez:\asus\documenti\unreal projects\worm\source\worm\WormHelperFunctions.h(25): error C2448: 'DebugMarkOccupiedBlocks': l'inizializzatore di
tipo funzione sembra essere una definizione di funzione
CompilerResultsLog: Error: Z:\Asus\Documenti\Unreal Projects\Worm\Intermediate\Build\Win64\UE4Editor\Inc\Worm\WormGameMode.generated.h(14) : fatal error C1189: #error: "WormGameMode.generated.h already included, missing '#pragma once' in WormGameMode.h"z:\asus\documenti\unreal projects\worm\intermediate\build\win64\ue4editor\inc\worm\WormGameMode.generated.
h(14): fatal error C1189: #error: "WormGameMode.generated.h already included, missing '#pragma once' in WormGameMode.h"
CompilerResultsLog: Error: Z:\Asus\Documenti\Unreal Projects\Worm\Intermediate\Build\Win64\UE4Editor\Inc\Worm\WormGameMode.generated.h(14) : fatal error C1189: #error: "WormGameMode.generated.h already included, missing '#pragma once' in WormGameMode.h"
CompilerResultsLog: Error: z:\asus\documenti\unreal projects\worm\intermediate\build\win64\ue4editor\inc\worm\WormGameMode.generated.h(14) : fatal error C1189: #error: "WormGameMode.generated.h already included, missing '#pragma once' in WormGameMode.h"
CompilerResultsLog: ERROR: UBT ERROR: Failed to produce item: Z:\Asus\Documenti\Unreal Projects\Worm\Binaries\Win64\UE4Editor-Worm-9504.dll
Apologize, I didn't yet figured out how to set my Unreal Engine in English...