Quantcast
Channel: Questions in topic: "error"
Viewing all articles
Browse latest Browse all 7934

Hi! i don't know how to solve this error. "object reference not set to an instance of an object"

$
0
0
using UnityEngine; using System.Collections; using UnityEngine.UI; public class HealthManager02 : MonoBehaviour { public static float health; public Slider healthBar; public int maxHealth; private int delayTime; public int healthDecrease; public int delay; private GameObject death; // Use this for initialization void Start () { healthBar = GetComponent(); health = maxHealth; health = 100; death = GameObject.Find ("Cell"); } // Update is called once per frame void Update () { healthBar.value = health; StartCoroutine(waitToSeconds(5)); } void OnTriggerStay2D(Collider2D other){ if (other.tag == "SunLight" && health < 100) { health = health + 0.14f; } } public void giveEnergy(int energyToGive){ health += energyToGive; } public void giveDamage(int damageToGive){ health -= damageToGive; } IEnumerator waitToSeconds(float delay){ health -= 0.08f; yield return new WaitForSeconds(delay); } }

Viewing all articles
Browse latest Browse all 7934

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>