void IsEnemyOnSight() // function display health bar enemy, if player can see him on forward { ray.origin = transform.position; // set ray from player position ray.direction = transform.forward; // to forward direction RaycastHit raycastHit; if (Physics.Raycast(ray, out raycastHit, sight, enemyLayer)) // if ray hit enemy raycastHit.transform.GetComponent<EnemyController>().DisplayHealthBar(); else enemyHealthBar.HideBar(); // bar will be unvisible }
IEnumerator DecreaseShieldTime() { while (currentShieldTime > 0) { shieldBar.UpdateBar(currentShieldTime, maxShieldTime); // update bar's appierrience currentShieldTime -= Time.deltaTime; // decrease shield's value yield return(null); // wait frame } shieldBar.HideBar(); // Hide bar when his value == 0 GetComponent <PlayerController>().ActiveShield(false); // disactive shield in PlayerController script, that he will susceptible by damage playerShield.SetActive(false); // turn off shield if time left; }