Local Varibles not been correct

Hi all,

I am writing a voxel engine and I require a function to perform a calculation to work out the centre of a cube. To that end I have this function in my UUBlock Class written in C++.

void UUBlock::Blockdata(AChunk* chunk, INT32 X, INT32 Y, INT32 Z, TArray<FMeshDataTriangle>& Triangles)
{

	this->BlockCenter.X = (float)((float)X*chunk->BlockSize) + chunk->BlockSizeHalf;
	this->BlockCenter.Y = (float)((float)Y*chunk->BlockSize) + chunk->BlockSizeHalf;
	this->BlockCenter.Z = (float)((float)Z*chunk->BlockSize) + chunk->BlockSizeHalf;
.......
}

when I call this method with a know BlockSize and BlockSizeHalf and know my X, Y, Z parameters.

my BlockCenter.X / BlockCenter.Y & BlockCenter.Z or always 0

which is rubbish when I have X = 5, BlockSize = 100 & BlockSizeHalf = 50

in this case BlockCenter.X should be 550.

Can someone please Advise as I am having these issues in serveral places in my code I don’t understand why simple Maths isn’t working.

Thanks for any advise or pointers.

You are setting BlockCenter.X twice and never BlockCenter.Z

When you break on line 6 in your function are every variable values right according to what you are expecting ? (check chunk member values, it seems that everything is 0 in your chunk)

The Variables that are passed in are what I am expecting. It’s the results that should be getting stored in the BlockCenter FVector that aren’t correct.

And i am literal at my wits end trying to understand why.