i honestly have no idea whats wrong there, maybe try halving the Y too?
Does your generations uses Zigzags or Straight offsets in grid?
This depends how you need structure placement.
I think it uses zigzag offsets.
If I half the Y value, then it would be z-clipping the tiles underneath it.
Can you show me function which places hexagons? (Part which calculates Vector3/CFrame where they should be placed, not just Hexagon.CFrame = smth
)
It is just a for loop:
(mapsize = 16; yMin = 1; yMax = 16)
for x = 1, mapSize do
for y = yMin, yMax do
for z = 1, mapSize do
local d = mapGet(densityMap, x*offset["x"], y, z*offset["z"])
--print(d, x*offset["x"], y, z*offset["z"])
if d >= 0 and d <= 0.14 then
local block = workspace.blockBase.Base_Plane:Clone()
--local block = Instance.new("Part", workspace)
--block.Size = Vector3.new(4, 4, 4)
z *= 3.732 * 0.5
block.Anchored = true
block.CFrame = CFrame.new((x*offset["x"])*4, y*4, (z*offset["z"])*3.732) -- this is the positioning
block.Color = Color3.fromHSV(((y/mapSize)%1), .75, 1 - (y/mapSize))
block.Parent = game.Workspace
end
end
end
game["Run Service"].Heartbeat:Wait()
end
Try to construct CFrame for hexagons using this base:
CFrame.new(0.866*(x - z%2/2), 0, z*0.75)
Idk what your offset.x mean, and why you multiply them by 4, 3.732, maybe they should be inserted like this:
(Note: dictionary[“Name”] == dictionary.Name, if Nameis string. Otherwise, use like you did, with [])
CFrame.new(0.866*(x*offset.x - z%2/2), 0, z*offset.z*0.75)
I wrote this base for tiles with hexagon diameter 1.
This works, but can you give me a base for a hexagon the size of 4?
Multiply X and Z values by 4
CFrame.new(3.464*(x - z%2/2), 0, z*3)
I have an issue: the following image shows a little offset issue that I can’t figure out. What do you suggest?
1st - your hexagons are not ideal =[
Ideal hexagon should have following size: (0.866, Y, 1)*N. (or swap X and Z if it still squashed)
My formula was for perfect hexagons.
Second - your hexagons have swapped X/Z axis, so swap positioning too.
CFrame.new(z*3, 0, 3.464*(x - z%2/2))
Thank you very much! That fixed it!
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.