I have a grid that I use as a map. I set an int value for the width and height but when I try to read these variables the game crashes.
If I try to print out the value just after setting it the game does not crash but from another function it will.
Declarations:
	UPROPERTY(EditAnywhere)
		int32 MapWidth;
	UPROPERTY(EditAnywhere)
		int32 MapHeight;
Functions:
void UGameMap::Generate(int32 Width, int32 Height)
{
	MapWidth = Width;
	MapHeight = Height;
   	Print(FString::FromInt(MapWidth)); //does not crash the game
	for (size_t x = 0; x < 50; x++)
	{
		for (size_t y = 0; y < 50; y++)
		{
			FWorldTile Tile;
			WorldTiles.Add(Tile);
		}
	}
}
bool UGameMap::InMapBounds(FVector2D TilePosition, FVector2D BuildingSize)
{
	Print(FString::FromInt(MapWidth)); //crashes the game
	if (TilePosition.X < 0 || TilePosition.X + BuildingSize.X > 50)
		return false;
		//|| TilePosition.X + BuildingSize.X > MapWidth || TilePosition.Y < 0 || TilePosition.Y + BuildingSize.Y > MapHeight)
	//	return false;
	return true;
}