- Home /
 
               Question by 
               Romano185 · Jan 04, 2012 at 02:22 PM · 
                guidisplaypercentageexperience  
              
 
              Displaying percentage on GUI
Hi everybody
I want to make an exp bar for my RPG, and I want to display the current exp as a percentage of the needed exp. So I've made this script:
 var maxexp = 50;
 
 var curexp = 10;
 
 var controlTexture : Texture2D;
 
 
 
 function Update () {
 
 
 
 if (curexp < 0) {
 
 curexp = 0;
 
 }
 
 
 
 if (maxexp < curexp){
 
 curexp = maxexp;
 
 }
 
 }
 
 
 
 function OnGUI () {
 
 
 
 if (maxexp >= 0){
 
 GUI.Button(Rect (0,78,500,26), maxexp.ToString(), "box");
 
 }
 
 
 
 if (curexp >= 0){
 
 GUI.Button(Rect (0,78,(curexp/maxexp*100),26), curexp/maxexp*100.ToString(), "box");
 
 }
 
 }
But when I add the script to a game object, it only displays the needed hp bar, and the bar displaying the percentage does only appear as a small bar at the left side of the screen, without displaying a number. And it also displays an error which says that the character T isn't expected.
Please help me
               Comment
              
 
               
              Answer by Eric5h5 · Jan 04, 2012 at 02:34 PM
You should use float division instead of integer division.
Your answer
 
 
             Follow this Question
Related Questions
Problem Displaying Score on GUI text 0 Answers
Display problem with OnGUI 3 Answers
How will display values like table? 1 Answer
Display a objects property. 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                