How can I get a ra.Tio of these areas to make them equal?

for some reason the smaller squares always have more but even tho I do .Magnitude.

Here’s the code that places calculates the block amount:

		local Size = Vector3.new(v.Size.X, 0, v.Size.Z)
local function GetPosition()
			return v.Position + (v.CFrame.LookVector * GetRandom(-v.Size.Z/2, v.Size.Z/2)) + (v.CFrame.RightVector * GetRandom(-v.Size.X/2, v.Size.X/2))
		end
		
		for i=1, Size.Magnitude do
-- debug part is a function outside of the code that just places that white part
			DebugPart(GetPosition())
		end

actually it’s not neccessarily a “ratio” I’m looking for but I just want a value that gets equalley bigger starting on 1 stud.

For example you have a 1x1 square. That’ll be one tree. a 10x10 square will be 10 trees. And so on.

I found a fix asking google’s AI but it caused my studio to hange for a second because the values were too high so I’ll post the code here in a second. (Original value was 0.2)



^ value 0.007

Code:

local TREE_DENSITY = 0.002

for _,v in script.Parent:GetChildren() do
	if v:IsA("Part") then

		local Area = v.Size.X * v.Size.Z 

		local NumTrees = math.ceil(Area * TREE_DENSITY) 

		local function GetPosition()
			return v.Position + (v.CFrame.LookVector * GetRandom(-v.Size.Z/2, v.Size.Z/2)) + (v.CFrame.RightVector * GetRandom(-v.Size.X/2, v.Size.X/2))
		end

		for i=1, NumTrees do
			DebugPart(GetPosition())
		end

	end
end

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.