- Home /
level up script please help
please help i have a very basic level up script for my mmo here it is:
var XP = 0;
var currentLevel = 1;
var LevelMultiplier = 1.5;
var NeededXP = 100;
if(XP > NeededXP)
print ("you've leveled up");
XP = 0;
(NeededXP * LevelMultiplier);
i want it to when i level up multiply the needed xp by 1.5 so it is harder to level up next time but it keeps saying at 10,11 Expressions in statements must only be executed for their side-effects. please help thank you
Answer by Jessespike · Nov 11, 2012 at 06:28 AM
The are a few errors here, first is you need to make certain that you use braces {} correctly. Putting the code in a Update function will also help. And lastly the NeededXP value is calculated but never assigned to NeededXP. The next bug is that currentLevel doesn't increment, but I'll let you try to figure it out.
function Update() {
if(XP > NeededXP) {
print ("you've leveled up");
XP = 0;
NeededXP = (NeededXP * LevelMultiplier);
}
}
I also recommend reading these:
http://forum.unity3d.com/threads/34015-Newbie-guide-to-Unity-Javascript-%28long%29
http://docs.unity3d.com/Documentation/ScriptReference/index.html