this would be good for simple maps that forever stay the same, but with player input the map can change quite a bit, but this is something i didnt actually know and mgith be pretty handy in the future!
It was meant to be an example of what it would look like. I’d recommend building your own grid and fine tuning it. It doesn’t need to expand the entire map but rather just a certain radius (i think anyway xd) Also I’m pretty sure you don’t need to use parts for this, you can use attachments to get the positions of the grid too
that also works, also i jsut figured out how the offsets worked, i jsut wanted the displays to be 1 stud nto realising that it also controls the offsets, so i can do that
but for the raidius thing,
that might have to be used, and with the suggestion from one of the posts above saying to make it only aim for edge if its sort of close, its also a pretty good idea for that, ill see what i can do with this and report back, tho i still have 0 clue on how to put a pivot point for the grid, but ill try and figure it out
im struggling with being able to position the center of the grid, how would i do this?
(heres what i did, making the position in the corner)
local gridSize = 50 -- Size of the grid (10x10x10)
local voxelSizeXZ = 5 -- Size of each voxel on X and Z axes
local offset = voxelSizeXZ / 2 -- Offset to center the grid
local PivotPoint = Vector3.new(54.863, 775.262, -57.502)
for x = 1, gridSize do
for z = 1, gridSize do
local voxel = Instance.new("Part")
voxel.Size = Vector3.new(1,1,1) -- Y is 1 stud
voxel.Position = Vector3.new(
(x * voxelSizeXZ - offset)+PivotPoint.X,
PivotPoint.Y,
(z * voxelSizeXZ - offset)+PivotPoint.Z
)
voxel.Anchored = true
voxel.Parent = workspace
end
end
to center it u need to adjust the position calculation is relative to the pivot point
The issue is the grid starts at 1,1 and extends to (gridsize, gridsize) which places the grid in the corner rather than centered around the PivotPoint
Try this;
local gridSize = 50 -- Size of the grid (50x50)
local voxelSizeXZ = 5 -- Size of each voxel on X and Z axes
local PivotPoint = Vector3.new(54.863, 775.262, -57.502)
-- Calculate the total size of the grid
local totalGridSizeXZ = gridSize * voxelSizeXZ
-- Calculate the offset to center the grid
local offsetXZ = totalGridSizeXZ / 2
for x = 1, gridSize do
for z = 1, gridSize do
local voxel = Instance.new("Part")
voxel.Size = Vector3.new(1, 1, 1) -- Y is 1 stud
-- Adjust the position to center the grid around the PivotPoint
voxel.Position = Vector3.new(
PivotPoint.X + (x * voxelSizeXZ - offsetXZ),
PivotPoint.Y,
PivotPoint.Z + (z * voxelSizeXZ - offsetXZ)
)
voxel.Anchored = true
voxel.Parent = workspace
end
end
also you can put all of the parts in a model if you havent already
This actually works great!
im goign to head off to bed since its getting late, but here is the code i have used, and i will put it to use when i can!
local gridSize = 50 -- Size of the grid (50x50)
local voxelSizeXZ = 5 -- Size of each voxel on X and Z axes
local PivotPoint = Vector3.new(54.863, 775.262, -57.502)
-- Calculate the total size of the grid
local totalGridSizeXZ = gridSize * voxelSizeXZ
-- Calculate the offset to center the grid
local offsetXZ = totalGridSizeXZ / 2
local function IsLocationTravelable(location:Vector3)
local rayinfo = RaycastParams.new()
rayinfo.FilterType = Enum.RaycastFilterType.Exclude
rayinfo.RespectCanCollide = true
--rayinfo.FilterDescendantsInstances = char:GetDescendants()
rayinfo.CollisionGroup = "Default"
local info = workspace:Raycast(location,Vector3.new(0,-20,0),rayinfo)
if info then
return info.Instance
end
return false
end
for x = 1, gridSize do
for z = 1, gridSize do
local pos = Vector3.new(
PivotPoint.X + (x * voxelSizeXZ - offsetXZ),
PivotPoint.Y,
PivotPoint.Z + (z * voxelSizeXZ - offsetXZ)
)
if not IsLocationTravelable(pos) then
local voxel = Instance.new("Part")
voxel.Size = Vector3.new(1, 1, 1) -- Y is 1 stud
-- Adjust the position to center the grid around the PivotPoint
voxel.Position = pos
voxel.Anchored = true
voxel.Parent = workspace
end
end
end
Thank you so much!
no problem im happy this worked for u