- Home /
Unexpected symbol `void' in class, struct, or interface member declaration
using UnityEngine;
using System.Collections;
public class PlayerHealth : MonoBehaviour {
public int maxHealth = 100;
public int curHealth = 100;
public float healthBarLengh;
// Use this for initialization
void Start () {
healthBarLengh = Screen.width / 2;
}
// Update is called once per frame
void Update () {
}
void OnGUI() {
GUI.Box (new Rect (10, 10, healthBarLengh, 20), curHealth + "/" + maxHealth);
}
public void AddjustCurrentHealth(int adj) {
curHealth += adj;
if(curHealth < 0)
curHealth = 0;
if(curHealth > maxHealth)
curHealth = maxHealth;
if(maxHealth < 1)
maxHealth = 1;
healthBarLengh = (Screen.width / 2)* (curHealth / (float)maxHealth);
}
}
Comment
The compiler is helpful enough to provide you with a line number where it found the problem. Can you share that line number with us so we don't have to look through your code line by line.