Hello again, i have script for a Experience bar, but experience is only +1, and i need experience +10. Please can you help me? Experience bar script Code (csharp): var curExp : float; var maxExp : float; var level : float = 1; function Update () { if (curExp >= maxExp) { print ("LevelUp" + level); curExp = 0; LevelUp(); } curExp ++; } function LevelUp() { maxExp += 20; level ++; } Thanks
So do curExp += 10 instead of curExp++ ? Not sure what the problem is... Also, your level should be an int not a float.
Thank you very much. But now i have second problem. I have texture and when curexp + texture + and when you have level 20 texture exceeds my computer screen. And i need texture that increases ranging from 10 to 800. Perhaps you understand. For understand: texture start in 20 resolution screen and end in 800 resolution screen. Exp bar script texture Code (csharp): var curExp : float; var maxExp : float; var level : float = 1; var expTexture : Texture; function Update () { if (curExp >= maxExp) { // It means we have leveled up print ("LevelUp" + level); curExp = 0; LevelUp(); } curExp += 10; } function OnGUI() { GUI.DrawTexture(Rect(300, 500, curExp, 30), expTexture); } function LevelUp() { // Increase our max exp maxExp += 20; level ++; } for example: texture increases in a range
Not sure how your XP bar works but try changing Code (csharp): GUI.DrawTexture(Rect(300, 500, curExp, 30), expTexture); into: Code (csharp): GUI.DrawTexture(Rect(300, 500, w *(curExp/maxExp), 30), expTexture); where w= the maximum length that you want to draw the XP bar. I think maybe you said 800?