Hello, I was wondering how to equally divide parts into a snail shape around a center part, I have attached an image below visualizing what I’m talking about.
Any help is appreciated
Hello, I was wondering how to equally divide parts into a snail shape around a center part, I have attached an image below visualizing what I’m talking about.
Any help is appreciated
By “equally divide” what exactly do you mean? Equal distance along the line (which is never ending so would literally never happen) or equal distance in 3D space (ignore the line)? Or do you mean generate parts based on that spiral sequence with a given distance from each other relative to the line?
Generating parts based on the spiral sequence order, each part only being on stud in size (1,1,1).
So are you generating them all at once or one at a time in order? I have an idea for how to implement this, but I’m confirming.
(if you’re generating them all at once then there’s no point, if there’s one every stud it’s the same as just generating X 1x1 blocks in a square)
One at a time in order, with each part being the size of one stud.
local part = game.Workspace:WaitForChild("Part") -- change to part name
local function GenerateSnail(position: Vector3)
local numTurns = 100 -- change to the amount of parts you want to spawn
local waitTime = 0.1 -- change to wait time in seconds
local direction = 1 -- 0 = north, 1 = west, etc
local forward = 0
local lastPos = position
for i = 0, numTurns do
for j = 0, math.floor(forward) do
local newPart = part:Clone()
newPart.Parent = game.Workspace
local directionVector = Vector3.new()
if direction == 0 then directionVector = Vector3.new(0, 0, -1)
elseif direction == 1 then directionVector = Vector3.new(-1, 0, 0)
elseif direction == 2 then directionVector = Vector3.new(0, 0, 1)
elseif direction == 3 then directionVector = Vector3.new(1, 0, 0) end
newPart.Position = lastPos + directionVector
lastPos = newPart.Position
wait(waitTime)
end
forward = forward + 0.5
direction = (direction + 1) % 4
end
end
GenerateSnail(part.Position)
Does this work? @adminaccount58
Sorry for the late replay, yes this works really well.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.