Tree Generates floating and on the bottom of the terrain

Yes, :MoveTo still performs faster. I did a test using 10201 models.

Code:

local startingTime = os.clock()

for i = -50, 50 do
	for j = -50, 50 do
		local Model = Instance.new("Model")

		local Part = Instance.new("Part")
		Part.Anchored = true
		Part.Parent = Model

		Model:MoveTo(Vector3.new(i, 0, j))
		Model.Parent = workspace
	end
end

print(os.clock() - startingTime)

local startingTime = os.clock()

for i = -50, 50 do
	for j = -50, 50 do		
		local raycast = workspace:Raycast(Vector3.new(i, 100, j), Vector3.yAxis * -100)
		
		if raycast then
			local Model = Instance.new("Model")

			local Part = Instance.new("Part")
			Part.Anchored = true
			Part.Parent = Model
			
			Model:PivotTo(CFrame.new(raycast.Position))
			Model.Parent = workspace
		end
	end
end

print(os.clock() - startingTime)

Performance:

MoveTo(): 0.4932608999997683
Raycasts: 0.9817652000001544

Again, I had one large part on the baseplate.

1 Like

It’s nice to know it’s been optimized finally

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