Quantcast
Viewing all articles
Browse latest Browse all 1488

Why is this script not working?

the script is meant to take away Enemy health and eventually destroy the enemy, however it does not work, and instead, I would be randomly shhoting an enemy, (NOT where the Target is,) and it would loose health, which is not what i want. the script is here:using UnityEngine; using System.Collections; using UnityEngine.UI; public class Enemyhealth : MonoBehaviour { public static int health = 1000; public GameObject Bot; public Slider healthBar; // Use this for initialization void Start () { InvokeRepeating("LooseHealth",1,1); } // Update is called once per frame void LooseHealth() { var laser1 = GameObject.FindWithTag("laser1"); var laser2 = GameObject.FindWithTag("laser2"); var Enemy = GameObject.FindWithTag ("bot"); if (laser1 == GameObject.FindWithTag("Enemy").transform) { health = health - 1000; } if (laser2 == GameObject.FindWithTag("Enemy").transform) { health = health - 1000; } healthBar.value = health; if (health <= 0) { Destroy (Bot); } } } any help would be appreciated

Viewing all articles
Browse latest Browse all 1488

Trending Articles



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