Thank you for the detailed response!
To clarify; I’m trying to limit force applied in reaching a target AngularVelocity to a set acceleration; I’m not attempting to accelerate indefinitely.
I’ve applied your solution and I’m still getting varying accelerations depending on part scale.
function calculateIntertia()
local size = part.Size
local x, y, z = size.X, size.Y, size.Z
local a = z
local b = y
local c = x
return (mass/12) * Vector3.new(b*b + c*c, a*a + c*c, a*a + b*b)
end
function setAccel(accel)
bVel.MaxTorque = calculateIntertia() * accel
end
I’m testing on a baseplate with zero gravity and a spinning cuboid part with different values for each size axis.
And I’m using the following script to benchmark the time it takes to reach the desired velocity:
local targetVel = Vector3.new(0,1,0)
local step = game:GetService('RunService').Stepped
wait(2) -- Wait a bit for roblox to start.
setAccel(Vector3.new(0,1,0))
bVel.AngularVelocity = targetVel
repeat
step:Wait()
until part.RotVelocity.Magnitude > 0 -- Wait for rotvelocity to start being applied.
local start = os.clock() -- Log the start timestamp.
repeat
step:Wait()
until part.RotVelocity.Magnitude >= targetVel.Magnitude -- Wait until the rotvelocity meets or exceeds the target rotvelocity.
print(os.clock() - start) -- Print the results.
Obviously this sort of hacky benchmarking solution is going to yield results with some error, but it still should yield results in a relatively consistent way relative to the inputs.
Anyway, when I set the cuboid part size to (12, 1, 12) with a mass of 100.8; I get results around 1.16 seconds.
However, for example: when I scale up the Y axis of the part for a total size of (12, 587, 12) with a mass of 59,169.598; I get wildly different results at 2.083 seconds.
It’s important to note that there is 0 gravity in the workspace and the part is suspended above the ground (so there are no friction forces acting upon it).