# Theory with level up and xp

Discussion in 'Scripting' started by Resilo, Dec 6, 2017.

1. ### Resilo

Joined:
Dec 8, 2016
Posts:
137
So just need some advice on the skill leveling system i need

so for example lets say i have the skill unarmed

and unarmed levels up at 3 xp

but it triples every level so level 2 will take be at 9 xp

so i think the easiest way is either with an array or a list

theoretically the list would just say that its 100 long(as the skills max is 100) and that every entry is 3* the last entry

what would be the best way to go about this? and what would a brief example look like?

2. ### MaxGuernseyIII

Joined:
Aug 23, 2015
Posts:
249
How accurate does it need to be? Math.Pow can get you darn close and will be very precise but it will lose accuracy as the number of xp required goes up because it uses floating point arithmetic.

If you need absolute accuracy in that formula, you'll want to use integers and loop through multiplication. Although, as I'm typing this, I'm realizing you can't have an integer that stores 3^100, so maybe you're stuck with floats/doubles anyway.

I'd try to find a way to be happy with doubles and Math.Pow...

3. ### LaneFox

Joined:
Jun 29, 2011
Posts:
6,499
Code (csharp):
1.         public static int GetXpRequiredAtNextLevel(int currentXp)
2.         {
3.             return currentXp * 3;
4.         }

Resilo and Ryiah like this.
unityunity