I’ve created a .h called WormHelperFunctions.h which is stored under Worm/Source/Worm folder inside my project and added the
include “WormHelperFunctions.generated.h” line as instructed by a random topic online (though I have no “WormHelperFunctions.generated.h” file anywhere).
I’ve clicked Worm.uproject and did GenerateVisualStudio Project Files.
I’ve did include “WormHelperFunctions.h” from my Pawn class generated from inside the engine, in the hope that this enable me to see those functions from inside the player blueprint editor.
But I’m getting an error when I compile, my .h and the error are both below.
Help please
.h:
#pragma once
#include "Engine/World.h"
#include "Classes/Kismet/KismetSystemLibrary.h"
#include "WormGameMode.h"
#include "WormHelperFunctions.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);
}
}
}
}
Error: