Infinite Level System?

I’ve created my classes and set things up, I have three ints (XP, NextLevel and Level) I’ve created a script in C# to manage the level system and at first I thought about using an Array to manually add the levels in to start with. Though I’m stuck on how to determine how much XP is needed for NextLevel.

I basically have a function that checks

if(XP > NextLevel) { LevelUp(); }

But inside my function for setting the amount of XP for NextLevel I’m not sure where or how to go about it.

Well, how much XP you would need for NextLevel depends on a lot of things. Like how fast should the player progress, how much xp should enemies give, should level progression speed be linear, exponential, logarithmic, etc.

Once you know that, you could calculate how much xp you need for the next level based on the xp required for the previous level, and set it to the new value in your LevelUp() function.

So, since it’s an infinite level system, you can’t set a specific amount for each level (like in an array or list). The best way to go about it is to come up with some sort of equation…Just for starters, you could arbitrarily choose a number (1.25 is as good as any). So, the first level would require 1000XP. Then level 2 would be 1250, etc…Anyways, not sure if this answers your question or not, but this is one method for doing what you are asking…

float levelMultiplier = 1.25;
function checkForNextLevel()
   if (xp >= nextLevelXP)

function levelUp()
   level += 1;
   nextLevelXP = nextLevelXP * levelMultiplier;

int initExp = 15; // write yours
float expMul = 1.2; // write yours

int LevelExp(level) {
    return (int)(Mathf.Pow(expMul,level-1)*initExp);