Hey guys,
I’m trying to make this health script but I cam across some errors. I was following a tutorial that I had saw, I think my problem is that the video is a little out dated. I was wondering if someone could help or fix these errors. Also here is the code if someone else wants it also the script is in C#
using UnityEngine;
using System.Collections;
public class PlayerHealth : MonoBehaviour {
public int Maxhealth = 100;
public int Curhealth = 100;
public float HealthBarLength
void Start () {
healthbarlength = Screen.width / 2;
}
// Update is called once per frame
void Update () {
Ajustcurrenthealth(0)
}
void OnGUI() {
GUI.Box(new Rect(10, 10, HealthBarLength, 20), Curhealth + "/" + Maxhealth);
}
public void Ajustcurrenthealth(int adj) {
curhealth +- adj
HealthBarLength = (Screen.width /2) * (Curhealth / (float)Maxhealth);
}
}
the errors I got were.
Assets/Scripts/Player Health.cs(9,12): error CS1519: Unexpected symbol `void’ in class, struct, or interface member declaration
Assets/Scripts/Player Health.cs(18,1): error CS1525: Unexpected symbol `}’
Assets/Scripts/Player Health.cs(28,16): error CS1525: Unexpected symbol `HealthBarLength’
Thanks for your help
Kind Regards
WarHawk.