I have a health bar scrip that only makes the bar go down just a tiny bit and repeat heres my script if you can tell me whats wrong thank you.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerHealth1 : MonoBehaviour {
public float max_Health = 100f;
public float cur_Health = 0f;
public GameObject healthBar;
void Start () {
cur_Health = max_Health;
}
void OnTriggerCollider(Collider other){
if (other.gameObject.tag == "enemyDong") {
cur_Health -= 1f;
float calc_Health = cur_Health / max_Health;
SetHealthBar (calc_Health);
}
}
public void SetHealthBar(float myHealth){
healthBar.transform.localScale = new Vector3(Mathf.Clamp(myHealth,0f ,1f), healthBar.transform.localScale.y, healthBar.transform.localScale.z);
}
}