Here is my script:
using UnityEngine;
using System.Collections;
public class Playerhealth : MonoBehaviour {
public int Maxhealth = 100;
public int Curhealth = 100;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void onGUI() {
GUI.Box(new Rect(10, 10, Screen.width / 2 / (Maxhealth / Curhealth) 20,), Curhealth + "/" + Maxhealth));
}
}
whats wrong with it?
Please format your code so it's readable, and copy the error message into your post so we can see the error message.
– StatementGUI.Box(new Rect(10, 10, Screen.width / 2 / (Maxhealth / Curhealth) 20,), Curhealth + "/" + Maxhealth)); the error is there, he is not finishing of the rectangle.
– EliteMossyThat, and you would get a division by zero at
– StatementScreen.width / 2 / (Maxhealth / Curhealth)when Curhealth reaches 0.. if it is applicable to your design.@Statement i don't really understand why he would divide the Maxhealth by Curhealth.
– EliteMossy