Besides, again, wheels always rotate around their axes. Wheels rotate on a hinge, and that hinge only spins in one direction. So you need to use RotVelocity:Dot(spinAxis)
to get the correct rotation direction and amount. This not only allows you to get whether or not a wheel is spinning forward or backward, but also how much it is spinning in the only axis that actually matters. Also, again, 30 / π
is 9.5492965855...
which may be close to 10, but it is not the same thing. Accurate calculations should use this ratio instead. Your calculations were probably inaccurate / estimates of the actual values. I recommend learning about dot products and some rotation conversion calculations.
http://hyperphysics.phy-astr.gsu.edu/hbase/rotq.html and https://en.wikipedia.org/wiki/Radian_per_second are good starts.
(the 60/(2π) aka 30/π already mentioned to verify). It is not complicated math, but it is pretty useful.
local ratio: number = 30 / math.pi
local angularVelocity: number =
cylinder.RotVelocity:Dot(
cylinder.CFrame.RightVector --or you can use the WorldAxis for the attachment
)
local wheelRPM: number = angularVelocity * ratio
local wheelVelocity: number = angularVelocity * wheelRadius --tangential velocity
Some useful things to do with this information:
Weighted average of wheelVelocities:
local totalTorque: number = 0
local averagedVelocity: number = 0
for i, wheel in ipairs(myWheels) do
totalTorque += wheel.TorquePercent
averagedVelocity += wheel:TangentialVelocity() * wheel.TorquePercent --or base it off of wheelRPM
--this way might be easier because it works for wheels of all sizes and allows for easier speed limiting
end
if totalTorque > 0 then
averagedVelocity /= totalTorque --this would get the average wheel movement speed
--this is great because free-spinning wheels (0% of torque output) have no effect on this number
--and you can balance this value based on power output, so this works for FWD, RWD, and AWD cars
end
--then you can use this property in things such as pitch shifting