Hello! I’m working on a Rythym game for Android where players can import their own songs with their own self made beatmaps.
The game is about tapping some circles that approach a position as their “tap time” approaches. These circles have a tap time, which is the time where they are supposed to be tapped, and a spawn time, which is used to spawn the circles a few seconds before their tap time is reached so that they have time to move torwards their position.
These circles use the following code to move:
initialTimeDiff = Mathf.Abs(currentSongTime - spawnTime); <---This is set on Start()
currentTimeDiff = spawnTime - currentSongTime;
transform.position = Vector3.Lerp(targetPos,spawnPos,currentTimeDiff/initialTimeDiff);
This works perfectly on the Unity Editor, however, on Android is where i’m finding issues.
Both doing Audiosource.time and Audiosource.clip.timesamples/Audiosource.clip.frequency give innacurate values.
By “innaccurate” i mean that the values seem to not update as fast as they should. I made a test to see whether it was a performance issue or something by adding a Time.deltaTime timer and a Audiosource.clip.timesamples/Audiosource.clip.frequency timer next to each other and seeing which of the two updated faster.
Time.deltaTime was updating as fast as expected, while the Audiosource timer was lagging behind a bit. Eventually the Time.deltaTime timer got out of sync with the song, so i had to discard using it for the game.
This issue causes the circles in the game to move as if they were “lagging” while everything else runs smoothly. This affects both the timing where the player is supposed to tap them too.
Anyone knows what is going on? I also found out that the issue got better by increasing the System Sample Rate to 96000 in the Audio settings, but i can’t make it go farther than that, so the issue is still there. I made a post before, but didn’t get any answers, so i decided to give it a shot and see if i could get help this time.
Any helps is appreciated! >_<