Creating a repeating Tempo Timer using the current audio time

Hello! I’m working on a beatmap editor for a rythymn game and have run into a bit of a wall now.

This is the situation: I have the song BPM already, i have the song current time. Now, i want to make a “repeating” tempo timer with these two things, but i don’t know where to go from here.

By “repeating tempo timer”, i mean sort of like a metronome which functions based on the current audio time position.

Let’s say, as the song timer goes up, the Tempo timer will “loop” using the time of a quarter note ( say, 0.5 seconds by doing (60000f/bpm)*0.001f) as a reset point each time it reaches 0. The timer will go from 0.5 to 0, and then back to 0.5 as soon as it reaches 0, using the current time of the song as the base for this.

I can’t make a looping timer with Time.deltaTime because the users will be able to jump from one song time position to another and the timer needs to stay synced with it.

I’m not sure where to go from this, and i hope i managed to explain myself well enough.

Any help is appreciated!

Not sure if this is what you mean but you could use the % (modulus/remainder) operator to work out where the time should be.

For example, if the current song time was 30.1 seconds and you did (30.1 % 0.5) you would get 0.1. Doing (30.6 % 0.5) would also get you 0.1 etc…

Ohhh thanks! This is exactly what i need :slight_smile: