I am new to unity. There will be two objects, object1 and object2, everytime object2 touches object2 the lifebar will decrease for example 10%, i have a code here it is already decresig but only once,i want the life bar to decrease everytime the object1 touches object2. Whats wrong with the code/ Please help me.
Thank you.
using UnityEngine;
using System.Collections;
public class HEALTH : MonoBehaviour {
public float deduction=0.10f;
public UISlider RING;
public static float _playerHealth=100f;
public UISprite gameover;
//public UISlider slider;
void Start(){
UpdateSubHealth();
}
public void OnTriggerEnter (Collider collider){
if(collider.gameObject.name.ToString() == "Torus001"){
_playerHealth-=deduction;
Debug.Log("Hit by Colliders " + collider.gameObject);
RING.sliderValue =0.10f;
UpdateSubHealth();
}
Debug.Log("XHit by Colliders " + collider.gameObject.name.ToString());
//UpdateSubHealth();
}
void UpdateSubHealth(){
}
}