Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

Level progress formula

Discussion in 'Scripting' started by Casual-Hit, May 11, 2018.

  1. Casual-Hit

    Casual-Hit

    Joined:
    Apr 20, 2014
    Posts:
    14
    Hi guys!

    First I want to say that I sucks at math.

    I need a formula to generate a number for my level system. That number will be the experience target.

    The formula should start from 100 and rise by 100 until level 10, at level 10, when the target is 1000, I want to change the ratio to 1000, so the target at level 11 will be 2000, 12 will be 3000, at level 20 the ratio should be 10000 and so on.

    I know I can do this with multiple variables but I want to use just the level var to generate this number.

    Thanks in advance! :)
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,599
    Just type in a table (an array of int for instance) of those numbers, maybe all the ones from 1 to 30, and use that until your game is finished.

    You will probably find you want to hand-tweak that table anyway long before you finish your game, so agonizing about developing a particular non-linear lookup formula will just be wasted time.

    Remember World Of Warcraft (WOW) shipped with like 50 levels if I recall correctly, so if you wanna be better than WOW, type in the first 51 level XP requirements and get on with your game.
     
  3. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,113
    Just a suggestion that the specific kind of experience requirement you're describing seems hard and frustrating, and unless you're game is really based on around this, you'll probably do better to give a smoother leveling curve.

    Your approach reminds me of old Everquest "Hell Levels". (https://wiki.project1999.com/Game_Mechanics#Hell_levels) Their XP requirements to go up a level were based on the level, and a multiplier. But the multiplier went up in steps at specific levels, causing very large gap to be created between certain levels. The impact on players is that every 5th level took a massive amount of XP to get through. What you have isn't exactly like that, but lets' say I'm moving along through the first 10 levels, your approach now requires me to get as much XP to get to level 11 as it took me to go from 1 to 10. That doesn't feel great.

    So, I'd recommend a smoother curve. Did you have a particular reason why the leveling shouldn't be relatively smooth?
     
  4. Casual-Hit

    Casual-Hit

    Joined:
    Apr 20, 2014
    Posts:
    14
    Thanks for your advice. :)

    I just got stuck into this and I cand sleep well until I solve the problem...

    The best solution until I figure out how to do this is the list method.

    Thanks again. :)
     
  5. Casual-Hit

    Casual-Hit

    Joined:
    Apr 20, 2014
    Posts:
    14
    The level curve is as smooth is possible because the scoring rise with the exp target, I just want to create an illusion of progressing, just for UX, as the game is an ultra casual game.
     
  6. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    I don't disagree with the comments here, but ...
    Code (csharp):
    1. #include <stdio.h>
    2. #include <math.h>
    3. int main()
    4. {
    5.     int lvl = 30;
    6.     int power = lvl / 10;
    7.     printf("Power = %d\n", power);
    8.    
    9.     int rem = power + lvl % 10;
    10.     printf("rem = %d\n", rem);
    11.    
    12.     int xp = rem * 100 * pow(10, power);
    13.    
    14.    
    15.     printf("exp = %d\n", xp);
    16.  
    17.     int xp2 = (lvl/10 + lvl % 10) * 100 * pow(10, lvl/10);
    18.     printf("xp2 = %d\n", xp2);
    19.     return 0;
    20. }
    xp2 is just a 1-liner. Sorry, didn't re-write it in C#. I think it's right.
     
  7. Casual-Hit

    Casual-Hit

    Joined:
    Apr 20, 2014
    Posts:
    14
    Thank you so much. I'll try it now. :)
     
  8. Casual-Hit

    Casual-Hit

    Joined:
    Apr 20, 2014
    Posts:
    14
    Code (CSharp):
    1. level / 10 + level % 10) * 100 * Mathf.Pow(10, level / 10)
    This line right here work's perfect. Thank you so much again. :)
     
  9. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    No problem. :)

    (that was just the same code without the intermediate variables and print statements. heh)