// Update is called once per frame void Update() { hitMarkerScript hitMarker = myHitIndicator.GetComponent <hitMarkerScript> (); if (HealthBar <= 0) { Application.LoadLevel("GameOver"); } if (HealthBar == 25) { healthBarImage.color = UnityEngine.Color.red; } else if (HealthBar > 25) { healthBarImage.color = UnityEngine.Color.white; } Change = (HealthBar * 0.01f) * 0.6784276f; //myHealthBar.transform.localScale = new Vector3 (Change, 0.3234372f, 1f); ScaleAround(myHealthBar.transform, myPivot.transform, new Vector3(Change, 0.3234372f, 1f)); if (Delay == true) { delayTime = delayTime -= 0.1f; hitMarker.gotHit = true; myHitIndicator.SetActive(true); } if (delayTime <= 0) { Delay = false; delayTime = 1; } if (HealthBar <= 0) { Debug.Log("Killed"); //Die //Application.LoadLevel("GameOver"); } // if (Input.GetKeyDown ("g")) { // HealthBar -= 10; // } }
// Use this for initialization void Start() { Delay = false; delayTime = 1; Image healthBarImage = GameObject.FindWithTag("HealthBar").GetComponent <Image>(); myHitIndicator = GameObject.FindGameObjectWithTag("hitIndicator"); hitMarkerScript hitMarker = myHitIndicator.GetComponent <hitMarkerScript> (); myHealthBar = GameObject.FindGameObjectWithTag("HealthBar"); myPivot = GameObject.FindGameObjectWithTag("pivot"); hitMarker.gotHit = true; }