I think nothing went wrong and it’s bug, but if somthing went wrong what went wrong?
error CS1525: Unexpected symbol `healthBar’
Plz forgive my name xD
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class HealthBar : MonoBehaviour {
public float TotalHp = 10;
public float CurrectHp;
public GameObject healthBar;
// Use this for initialization
void Start () {
CurrectHp = TotalHp;
CurrectHp = TotalHp;
}
// Update is called once per frame
void Update () {
InvokeRepeating("Damage", 0.0f, 1);
}
private void Damage () {
CurrectHp -= 1;
SetHealthBar ();
}
private void SetHealthBar() {
float ratio = CurrectHp / TotalHp
healthBar.transform.localscale = new Vector3(1,ratio,1);
}
}