Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

RotVelocity to get Rotations Per Second?

Asked by
iiSiv 10
10 years ago

Lets say I have a wheel and I want to get its rotations per second. I'm not experienced enough to use the wheel's RotVelocity relative to the object to get its rotations per second. I plan on making realistic vehicles in my upcoming game that features an elaborate sound code for the engine sounds. Accessing the vehicles' RPS is crucial to the script. I'm not looking for an entire script. Just a fragment of code that would help me with my development. Much appreciated.

1 answer

Log in to vote
0
Answered by
duckwit 1404 Moderation Voter
10 years ago

By taking the Magnitude of the RotVelocity (which is measured in Radians), you get the angular frequency, or "w" (Greek symbol 'omega').

Then use the formula:

w = 2 * pi * f

(in English)

angular frequency = 2 * pi * ordinary frequency

So, in Lua that'd be:

rotationsPerSecond = part.RotVelocity.Magnitude / (2*math.pi)
--Rotations per second is known as "ordinary frequency" in this case
0
Sounds good! I see how that works now. Thank you iiSiv 10 — 10y
Ad

Answer this question