- Home /
Experience system leveling prematurely
Alright, I've been tinkering with this leveling system, trying to input a way to make the exp requirement increase as your skill does (i am using Fallout 3's exp formula FYI) now the problem here is that it levels when it shouldn't. It is probably pretty obvious to you why, but i can't see it. I just need fresh eyes to look it over. Just to say the problem is NOT having my starting exp at 0, along with having the required exp at 0. I see that, and i did it with the intention of the tutorial level not allowing you to level up, so i would add a Boolean to disable the entire exp system till a specific time, when in which the character will level up (Fallout 3, and Elder Scroll, fans know what i am talking about). The problem is when the player gets to level 2 they need to get 200 exp to get to level 3. However it says that the player is at level 3 when it needs to get 200 exp. I do not understand why it is leveling up twice.
var guiTextEXP : GUIText; static var accumulatedExperiencePoints : int = 0; private var levelExpRequirements : int; private var currentLevel : int = 1;
function FixedUpdate () {
if(accumulatedExperiencePoints >= levelExpRequirements) {
var levelFormula1 : int = 3*currentLevel;
var levelFormula2 : int = levelFormula1+2;
var levelFormula3 : int = currentLevel-1;
var levelFormula4 : int = levelFormula2*levelFormula3;
var levelFormula5 : int = levelFormula4*25;
Debug.Log(levelFormula5);
levelExpRequirements = levelFormula5;
currentLevel += 1;
}
guiTextEXP.text = accumulatedExperiencePoints+"/" + levelExpRequirements + "|" + currentLevel;
}
Answer by Joe Ellis · Aug 23, 2010 at 08:07 PM
Move the currentLevel += 1; to the beginning of the block just prior to assigning levelFormula1. This way, you are calculating requirements based on the new level and not the previous level. Moving this line will cause this code to work as expected.
This is so funny, as i found this out JUST as you posted your answer...sometimes i make the stupidest mistakes...
Your answer
Follow this Question
Related Questions
PlayerPrefs reset error 0 Answers
Leveling up in RPG 1 Answer
new user very easy c# question regarding syntax 1 Answer
RPG tutorials/guides? 2 Answers
Need help with a proficiency system(experience system) 1 Answer