Question by
J0hn4n · Dec 12, 2016 at 01:51 AM ·
script errornull reference exceptionhealth-deductionhealth
NullReferenceException: Object reference not set to an instance of an object
public class MedPack : MonoBehaviour {
Hp Info;
public int Heal;
// Use this for initialization
void Start () {
Info = GetComponent<Hp> ();
}
int Healing()
{
Heal = Info.Health / 2;
return Heal + Info.Health;
}
// Update is called once per frame
void OnTriggerEnter2D (Collider2D Item) {
if (Item.gameObject.tag == "Player") {
Healing ();
Destroy (this.gameObject);
}
if (Item.gameObject.tag == "Enemy"){
Healing ();
Destroy (this.gameObject);
}
}
}
Comment
Am triin to make a Health manager, will check object actual HP and will heal the half of his actual life.
but when a object pick up the medpack a error happens.
Your answer
Follow this Question
Related Questions
how can i fix my java script errors? 0 Answers
Enemy dies in editor mode but not in build 2 Answers
Health system in a text based game. 2 Answers
Why is this script not working? 2 Answers
how to put in a delay in void 1 Answer