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.)

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).

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);.