- Home /
Exponential XP (Beginner)
I'm relatively new to any sort of coding; C# especially.
I'm still learning and I know this might seem pretty trivial but I'm trying to figure out how to go about making a xp/leveling system that goes off of xp that isn't of a liner fashion. IE. Not, 50, 100, 150, etc.
Obviously, you could math it out and set the xp req per level. But is there a way I can do it with just a couple lines of code? And would you have to change anything as far as the typical "leveling" scripts go?
If you had something like:
if(currentXP >= nextLvlXP(currentLVL))
{
currentLVL+=1;
}
Or would you have to make some changes to it?
Also, I was looking for some examples or reference but, I'm not sure if this is what I'm looking for.
And I'm sorry if the code sample didn't work, I clicked on it and used it however it doesn't look like the code that's shown like in everyone's posts here (Although maybe it just doesn't show up in preview?).
Thanks for the time! :) Hopefully I explained myself well enough (I'm tired!) And, does anyone else have a ridiculously hard time with tags?
EDIT: Broken link was broken.
Ins$$anonymous$$d of doing what you would do in a linear fashion, you'd add an exponential to the calculation. You should post nextLvlXP.
Be careful not to forget to check for whether the player gained enough exp to level up twice. In your pseudo-code if the player gets enough xp to level up twice it looks like they'll only level up once.
Answer by Bunny83 · Apr 28, 2014 at 10:15 AM
As you can easily find on the net, most games ( which involves XP )seem to be based on a quadratic function and not exponential. The exponential function has the "little" problem that it grows way too much when you go higher. You could compensate it a bit by increasing the XP gain with each level also in a exp-fashion.
If you have a XP <-> level relation ship based on the quadratic function like this:
level = Mathf.FloorToInt(constant * Mathf.Sqrt(XP));
You can calculate the required XP for a certain level like this:
XP = (level*level) / (constant*constant);
I think answers should be reserved for actual answers, not comments.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
My character jumps infinitely, even when in mid-air 1 Answer
Distribute terrain in zones 3 Answers
Edit this code? 0 Answers
Pushing More GUI Clips Than Popping 0 Answers