Hi again. Yet another question from me. (I’m learning!)
I’ve been doing a lot of searching regarding this but have yet to find anything useful and as you probably know, I’m not a genius when it comes to scripting, so I’m asking here.
I’m making a game. (my Skyroads-like game I keep mentioning in my questions)
The next thing I really need to do to make way for other things, is set up a best time/high score system.
Throughout each stage there will be a timer running from the beginning to the end. It will be counting up of course. I want it to get the time at the end, check to see if it’s the “best time” and save it. (I guess in PlayerPrefs) I want each individual stage/level to have its own best time of course. Then, at the level select screen, there will be a “Best Time” below each level and it will display the “best time” for that level/stage.
I already have a timer counting up. I haven’t told it when to stop yet, since I don’t actually have a complete level that “starts” and “ends” but I’ll get to that.
I’d just like a place to start. You don’t need to write any code out for me if you don’t want to. I just want some direction. I’ve looked into PlayerPrefs a bit, looked at other high score questions, but they’re all about a high score table with a name and all that. I just want ONE “high score” (best time taken from the Timer’s variable at the end of the level I guess) to be saved and displayed on the level select screen at a certain point on the screen. (Of course) Plenty of other things I might do with it, but I can figure all that out myself. For now I just need some help figuring this out.
……
TL;DR, I want to do this:
- Have a timer counting up (on any given stage, whatever, this is already done, unless I need to re-do it to make up for the method I’ll use to save it and all)
- Save the timer’s “time” when a certain thing happens (the level is “completed”, I guess a boolean or something, whatever, not important)
- Check to see if it’s the best time (check the previous best time, if there is none, then it should be 0 or something and it will know there is no best time, so it is automatically the best time)
- Display the best time somewhere. I’m not asking for you to write it all out for me, just pointing me in the right direction with a few tips will do.
Sorry for such a long post, I’m somewhat of a perfectionist.
Thanks for any help in advance.