Search Unity

Timer and highscore

Discussion in 'Scripting' started by Voumerus, Nov 8, 2010.

  1. Voumerus

    Voumerus

    Guest

    Joined:
    Mar 4, 2010
    Posts:
    107
    I'm trying to get a timer that counts from 0 when the level starts and stop when a sphere reaches an area(invisible trigger) once the sphere has touched the trigger a leaderboard would appear for that level giving the player the option to enter their name and to update their time if they have a new record on the level, within this leaderboard GUI there would be Exit, Restart and Next buttons

    I've searched for timer scripts but unfortunately not managed to get anything working the way i want and i'm a little lost for direction

    I did research into online highscore last night and found
    http://www.unifycommunity.com/wiki/index.php?title=Server_Side_Highscores
    i did understand some of it but once again a little lost for direction

    the game is going to be played via web browser and will be played from my website

    Can some one show me the light :p?
     
  2. appels

    appels

    Joined:
    Jun 25, 2010
    Posts:
    2,687
  3. Voumerus

    Voumerus

    Guest

    Joined:
    Mar 4, 2010
    Posts:
    107
    As i said i understand some of it but i'm still a little lost, for example in the HS controller script description says
    "You need to be able to supply it with a string containing the players name, and a string containing the players score"
    I'm not sure what that means.

    The timer you linked me to left me confused also, i've never dealt with timers before and have only recently started to get the basics of scripting.

    Also i'm confused as to how i would go about making a timer script communicate the other scripts to get the score added to the database, i could just over thinking it and maybes it's all laid out in front of me already but i can't see it :p another thing how would i go about making a GUI pop up after each level.

    My apologies if these are very very simple things to do but we all have to start somewhere :)
     
  4. kweiko

    kweiko

    Joined:
    Mar 9, 2010
    Posts:
    103
    Hello, well no need to apologize, the highscore thingy is pretty advanced since you're linking it to a server. That is beyond my current knowledge, but "You need to be able to supply it with a string containing the players name, and a string containing the players score" means that you need two String variables, one for the name and one for the score which you'll send to "it", so that you could store them. I know that you usually use int/float for the scores, so before sending the score, convert it to a string, and then send it.

    As for the timer, what appels meant was, that you could use the function Time.timeSinceLevelLoad() to count up from when the level starts. This function is resetted everytime a new scene is loaded. There is another function, Time.Time() that will count from when the game starts, so that won't be useful for you.

    So, have a timer variable so that you could manipulate the timer, preferably a float, and update it every frame by adding to it the time since the level started:
    Use a tag for the trigger and whenever the sphere touched the it, use

    My suggestion is to skip the server side highscore, and just try to implement a highscore that stores the data as long as the game is run. Unless you have knowledge in MySQL and database management that is!

    Hope that helped
    /Kweiko
     
  5. Voumerus

    Voumerus

    Guest

    Joined:
    Mar 4, 2010
    Posts:
    107
    Hey thanks for the reply, the timer is making a little more sense now, i think i might be able to work from that code :) i've decided to buy a high scores tutorial to help progress further as i can't find free tutorials that are targeted at my level of knowledge anywhere.

    Thanks for the replies :)