Converting a Rotation Spin speed to RPM
So technically this is a musical app, so I would like to express the variable as BPM. But it is a radar spinning around a circle, therefore it is an RPM speed also.
Here's the script I use to spin my radar line within the circle:
using UnityEngine; using System.Collections;
public class Spin : MonoBehaviour {
public float speed = 10f;
// Update is called once per frame
void Update () {
transform.Rotate (Vector3.forward, speed * Time.deltaTime);
// {
//}
}
}
Questions: - What is this speed? I'm guessing the 'f' is for frames. But how is this expressed? i,e, MPH, KPH - How could I script a conversion to the RPM/BPM? (Assuming 4 beats/revelation, something like this.)
Answer by AurimasBlazulionis · Dec 18, 2016 at 09:06 PM
f stands for floating point (number with decimal places). So, the rotation speed is 10 degrees per second, because every frame, you rotate by that value multiplied by how long did it take for the last frame to get rendered.
If you need to use RPM, just do something like transform.Rotate (Vector3.forward, (60f / rpm) * Time.deltaTime);
.
Answer by DiGiaCom-Tech · Jul 26, 2017 at 12:18 AM
360° rotation in one (1) minute is equal to 6° per second (DPS). Because everything we do has to be metered in seconds the code should be ...
transform.Rotate (Vector3.forward, RPM * 6f * Time.deltaTime);
This gives a true representation of 'Revolutions Per Minute' (RPM).
Your answer
Follow this Question
Related Questions
How do I go back to the normal walking speed? 0 Answers
3 Axis Camera Rotation 0 Answers
Record and replay movement 0 Answers
Stop moving gameObject and push it back 0 Answers
Questions about Rotations in unity 1 Answer