Padding Math Help

So most of us know what padding is, if you dont an example is…
“You have a part and you want other parts to spawn along one axis of that part equally spaced apart from eachother”

So, I want to do what’s in that example but I cant figure out the math for it Please Help.

Can you explain more? You mean you want to spawn multiple parts equally apart from each other on the same axis?

local amount = 100
local part =  --define a part that is in the workspace
local last = part
local spacebetween = 2 --studs apart


for i = 1, amount, 1 do
      local clone = part:Clone()
     clone.Parent = game.Workspace
     local distance = part.Size.X/2 + spacebetween
     clone.Position = last.Position + Vector3.new(0,distance,0)
     last = clone
end

It is better to use the edge of the part when adding the padding. Using the center and giving it 0 padding would create collisions even though padding is 0 not negative. And you probably want to use the Y axis to get the edge since you are adding in the Y axis.

So this would be better:
local distance = part.Size.Y + spacebetween
Instead of
local distance = part.Size.X/2 + spacebetween

Yeah, well he didn’t specify which axis. Well either would work, but if its the Y axis you need to do part.Size.Y/2 because half of it is above the center point and half is below.

That’s my point. Using the edge and giving it 0 padding would mean that there is no space between the parts and no overlapping. However, since you are using the center of the part, 0 padding would cause overlapping.

1 Like