I am making a dice game and the problem i have is not the dice rolls, but the fact that OnGUI is not showing the “unbanked” score at the bottom of the code.
#pragma strict
function Start () {
}
//
var dice1:int;
var dice2:int;
var dicetotal:int;
var runningscore:int;
var unbanked:int;
function Update () {
if(Input.GetKeyDown("space")){
dice1=Random.Range(1,7);//make the dice show 1-6
dice2=Random.Range(1,7);//make the dice show 1-6
}
if (dice1==1||dice2==1){
badroll();
}
if(dice1>1&&dice2>1){
gettotal();
}
}
function badroll(){
dicetotal=0;
}
//
function gettotal(){
dicetotal=dice1+dice2;
unbanked=dicetotal*3000;
}
function OnGUI(){
GUI.Label(Rect(10,10,100,20),"You rolled a "+dice1);//dice1 throw
GUI.Label(Rect(10,30,100,20),"You rolled a "+dice2);//dice2 row
GUI.Label(Rect(10,60,100,20),"JUST EARNED "+unbanked);//
}
For any help, please format your code. You can do this by highlighting all your code, then clicking the 10101 button at the top of the edit window. Watch : http://video.unity3d.com/video/7720450/tutorials-using-unity-answers
– AlucardJay