- Home /
The question is answered, right answer was accepted
Add to number little by little so it ends at specific number.
Hey guys,
Sorry about the weird title, but I can't think of any concise way to ask this.
I'm trying to make a timebar (similar to this), but I can't figure out how to position the place marker every frame. I know I'll have to use audio.time to get the place in the song, but I don't know how to convert that into the length of the timebar (which is a variable length).
Incase this isn't clear, let's say the timebar is 800px wide, audio.time is currently 243.8 and the clip.length is 571.6. The place marker isn't going to be correctly positioned if I just use the audio.time value, so how would I make sure it'll end at 800px when the song reaches 571.6?
If you can think of a better way for me to explain this, please let me know.
Thanks for taking the time to read this! -Gibson
Answer by KiraSensei · Jun 08, 2013 at 09:47 AM
Have a look here
You can try something like :
float x = audio.time;
float currLength = x * 800 / clip.length;
Use this code in the Update method. Then you can update the slider (or whatever gui object you use) accordingly to currLength value
Thanks for the answer, $$anonymous$$iraSensei, and thanks for providing the link so I can learn more about this.
Follow this Question
Related Questions
How to adjust In-Game volume in C#? 1 Answer
The Game Over creating with audio? 1 Answer
Downloading Audio Durin RunTime.. 1 Answer
Detect GUI rotation degree 1 Answer
let player import music during game? 2 Answers