private void Update() { Vector3 directionToEnemy = this.transform.position - torch.transform.position; Vector3 forward = torch.transform.forward; float angle = Vector3.Angle(forward, directionToEnemy); if ((angle + 30) < torch.GetLightAngle()) { inverter = -1; timeLighted += Time.deltaTime; if (timeLighted > timeToDisappear) { Destroy(this.gameObject); } } else { inverter = 1.5f; timeLighted = 0; } }