private void Update() { float ratio = (timeManager.WorldTime - timeActivated) / lifeSpan; if (ratio > 1f) //end of power, check for enemies to damage { List <Health> allHealths = Health.AllHealthComponents; foreach (Health h in allHealths) { if (h.gameObject.activeSelf && h.Alive) { float sqrMag = (transform.position - h.transform.position).sqrMagnitude; if (sqrMag < maxRange * maxRange) { if (h != GameManager.ActiveGameManager.Player.Health) { if (MainFemale.CanSeeTarget(transform.position + Vector3.up, h)) { h.DamageHealth(damage); } } } } } gameObject.SetActive(false); } else { rend.transform.localScale = Vector3.one * Mathf.Max(ratio, 0.02f) * maxRendScale; } }
private void Update() { float ratio = (timeManager.WorldTime - timeInit) / attackTime; if (ratio > 1f) { if (MainFemale.CanSeeTarget(transform.position + Vector3.up, target)) { target.DamageHealth(15); } gameObject.SetActive(false); } else { rend.transform.localScale = Vector3.one * ratio * rendMaxScale; float theta = -Mathf.Atan2(target.transform.position.z - transform.position.z, target.transform.position.x - transform.position.x) * Mathf.Rad2Deg + 270; rend.transform.rotation = Quaternion.Euler(270, theta, 0); } }