Hey, I want to spawn parts randomly in a circular area, something like this
I just cant find the correct math and algorithm for it
Thanks.
Hey, I want to spawn parts randomly in a circular area, something like this
For a disk like this, simply :
local rand = math.random
local function getPointInDisk(center, radius)
return center + radius * rand() * Vector3.new(1 - 2 * rand(), 0, 1 - 2 * rand()).Unit
end
local newPart = Instance.new("Part")
newPart.Position = getPointInDisk(Vector3.zero, 5)
newPart.Anchored = true
newPart.Parent = workspace
Note that this only works for X-Z plane. To make this work for an arbitrary plane, you need a bit more involved math.