I'm creating an RPG game (using C# in Unity API) that uses a leveling system. I went to the Desomos Online Graphing Calculator and created the following curve representing the levels based on experience: https://www.desmos.com/calculator/bsvkba4qg1. Note that the Y-intercept is at approximately (0, 1).

My Character class has the following fields representing the experience curve from above:

public float experience { get; set; }

public int level {
        float level = experience / 120;
        level += 1.123f;
        level = Mathf.Log(level);
        level *= 20;
        return Mathf.FloorToInt(level);

However, when the game begins and experience defaults to 0 as floats do, level returns 2. When experience is 100, level returns 13. Clearly there is some error on my part. Have I entered my formula wrong? If so, how can I fix it, and if not, what else might be the problem?


In your Desmos graph, you are using log base 10, however your unity function is using log base e (natural log, often abbreviated ln). To specify that you want log base 10, you need to add a second argument like the example below. See Mathf.Log() for details.

 level = Mathf.Log(level,10);
  • \$\begingroup\$ Thank you so much. I knew it was something simple. It seems I have forgotten a thing or two from my school days. Cheers! \$\endgroup\$ – Tanner Fix-It Smith Feb 24 '17 at 2:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.