I’m new to unity coding but I was just trying to do my death script with the GUI for the lives too. I’m getting some errors that I don’t understand.
Assets/MyScripts/GUIcam.js(21,10): BCE0044: expecting (, found ‘OnGUI’.
Assets/MyScripts/GUIcam.js(21,18): UCE0001: ‘;’ expected. Insert a semicolon at the end.
Assets/MyScripts/GUIcam.js(22,1): BCE0043: Unexpected token: if.
Assets/MyScripts/GUIcam.js(22,16): UCE0001: ‘;’ expected. Insert a semicolon at the end.
Assets/MyScripts/GUIcam.js(23,59): BCE0044: expecting :, found ‘;’.
I understand what most of the error’s mean but if you look at the line numbers it gets confusing.
var icon1 : Texture2D;
var icon2 : Texture2D;
var icon3 : Texture2D;
var dead = false;
var Lives = 3;
function OnControllerColliderHit(hit : ControllerColliderHit){
if(hit.gameObject.tag == “Dead”){
dead = true;
if (Lives == 3){
Lives == 2;
}
if (Lives == 2){
Lives == 1;
}
if (Lives == 1){
Lives == 0;
}
}
function OnGUI (){
if (Lives == 3){
GUI.Box (Rect (10,10,100,100), GUIContent(icon3));
if (Lives == 2){
GUI.Box (Rect (10,10,100,100), GUIContent(icon2));
if (Lives == 1){
GUI.Box (Rect (10,10,100,100), GUIContent(icon1));
}
}
}
}
}