Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

my first simple script need a bit help

Discussion in 'Scripting' started by dr-mad, Feb 20, 2010.

  1. dr-mad

    dr-mad

    Joined:
    Feb 15, 2010
    Posts:
    19
    hi i am tryingt to make a skill system but in another program it works now i try it to make it work

    this is my first script its very simple i make it so that if i click my mouse its set xp and if i get the level or above then it adds a new curLevel(currentlevel)


    here it is

    Code (csharp):
    1.  
    2. public var Xp = 0;
    3. public var Level = 120;
    4. public var curLevel = 1;
    5.  
    6. function Update ()
    7. {
    8.     if(Input.GetMouseButton(0)) {
    9.         Xp + 50;
    10.         }
    11.    
    12.    
    13.     if (Xp > Level)
    14.     {
    15.         (Xp > 0 (curLevel = +1));
    16.         Xp = 0;
    17.         Level = Level + Level * 0.2;
    18.        
    19.        
    20.     }
    21.    
    22.    
    23. }
    24.  
    25.  
    need a bit help ;) to get it to work most of it is done need only some bug fixes but i dont understand these yet

    greets dr-mad
     
  2. chhenderson

    chhenderson

    Joined:
    Feb 15, 2010
    Posts:
    10
    I assume this is the effect you were going for. Clicking adds to your experience, when a target is reached, you gain a level.

    Actually I spruced it up a little too. The last line makes it so that every time you level up it takes more experience to get to the next level.

    Code (csharp):
    1. public var Xp = 0;
    2. public var LevelUp = 120;
    3. public var Level = 1;
    4.  
    5. function Update ()
    6. {
    7.  
    8.    if(Input.GetMouseButtonDown(0))
    9.    {
    10.       Xp += 50;
    11.     }
    12.    
    13.    if (Xp >= LevelUp)
    14.    {
    15.       Level += 1;
    16.       Xp = 0;
    17.       LevelUp *= 1.5;
    18.    }
    19. }
    20.  
     
  3. dr-mad

    dr-mad

    Joined:
    Feb 15, 2010
    Posts:
    19
    thanks ;) now i know how to code is thanks ;)