Performance question: Hinge constraints or CFrames?

Which is more performant for my game, CFrames or use a hinge constraint to rotate turrets and wheels?

2 Likes

Hello, did you figure it out? I have the same question.

No. still didnt figure it out. No one helps

Oh thats sad. Thank you for a quick reply tho :))

Depends.
If you need use of physics - then go for hinges.
If you can just ignore it - then use CFrames (if your entire tank need physics but turret is “welded”, then you still can use CFrames)
CFrames are more performant than constraints, but constraints are easier to deal with.

2 Likes

Hmmmm, not sure about your last point, so basically in my case with 20 models spinning, the hinge constraint is definitely better. I conducted a test with 20 parts spinning using the most efficient method with CFrame, and then with the hinge constraint. There was a 10 FPS drop when using CFrame, even at slower speed.

How in the hell you managed to lag 20 CFrame operations???

it didn’t lag, in my case fps drop is from average 235 to 225

Can you show code which you used for CFrames (and model you rotated)

local RunService = game:GetService("RunService")
local rot = CFrame.Angles(0, math.rad(0.5), 0)
local partsFolder = workspace:WaitForChild("Parts")
local parts = partsFolder:GetChildren()

RunService.Stepped:Connect(function()
	for _, part in pairs(parts) do
		part.CFrame *= rot
	end
end)

model:
image
7 parts in a model

Idk what’s wrong in your situation. This shouldn’t cause even 0.5 fps drop.

1 Like

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