Search Unity

How to script and display score

Discussion in 'Scripting' started by Benjeta, Oct 23, 2014.

  1. Benjeta

    Benjeta

    Joined:
    Oct 22, 2012
    Posts:
    1
    Hi everybody, I'm learning scripting and in my game I need a specific script.

    I'm making a game that mashup 3D and 2D scenes.

    Ok so, I need a script doing this :

    When the player enter a object collider (object tag = Bonus) add 500 points to the total score and destroy the object.

    if the object tag is (object tag = Small Bonus), add only 250 points and destroy the object.

    If the player die so, restart the level but reset the score to the first time the player entered the level.

    Exemple : If the player finish the level 1 with 500 points, start the level 2 with always 500 points obviously, and if he die after picking up some points, restart the level with 500 points. If the player finish the level 1 with 500 points and finish the level 2 with 1000 points, so, start the level 3 with 1500 points. If he die, restart the level with 1500 points... and so on ^^

    The score need to be at the top middle and never being destroyed. So if the player change scenes, the score will be always there. That's it.

    I need this in JS please, I can learn more easily in JS !

    I'm looking for help to write my own code. I'm really new to scripting. I'm making the music, the 3D, the 2D Sprites and all the stuff, I only need a little help to be able to script scoring. My knowledge in scripting are really weak. I only know some basics atm. But I learn really quick and all my scripts are done by myself. And i'm proud of me. I've even accomplished an IA. But like it's my first time using fixed parameter at load level or even, using GUIText ... I don't know how to proceed !

    P;S : I'm french, sorry for my bad english.
     
    Last edited: Oct 23, 2014