private void Shoot() { var hits = PositionUtil.RayAllFromTo(gameObject, Target, Range); foreach (var hit in hits) { var dmg = hit.transform.gameObject.GetComponent <Damageable>(); var team = hit.transform.gameObject.GetComponent <Team>(); if (dmg == null || !AffectedTeams.Contains(team.TeamId)) { continue; } dmg.Damage(Damage); break; } Destroy(gameObject); }