I wrote the following code for my Rhythm game, but there seems to be some issues
=========================================================
public class gm : MonoBehaviour {
List whichnote = new List() {1,2,3};
public int notemark = 0;
public Transform qObj;
public string timerReset=“y”;
public float xPos;
public static int Combo = 0;
public Transform Tencombo;
public string Combospawn = “n”;
public static float totalscore = 0;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update()
{
if (timerReset == “y”)
{
StartCoroutine(spawnnote());
timerReset = “n”;
}
if ((Combo==10) && (Combospawn==“n”))
{
Combospawn = “y”;
Instantiate(Tencombo, new Vector3(0.16f, 3.15f, 1.05f), Tencombo.rotation);
}
}
IEnumerator spawnnote()
{
yield return new WaitForSeconds(0.34285f);
if (whichnote [notemark] == 1)
{
xPos = -50f;
}
if (whichnote [notemark] == 2)
{
xPos = -13f;
}
if (whichnote [notemark] == 3)
=========================================================================
To summarize, the game spawns a note in whatever position you list it to do, waits for however many seconds you tell it to (for example: mine is .34285, which is 175 bpm), then spawns the next note in the list. However, in-game the notes spawn at different times than I tell it to do, making the song out of sync with the game.
If you know the purpose of this, a fix, or another way of calculating bpm, please tell me. Any help is appreciated.