void Update() { transform.position += direction.ToVector3() * Speed * Time.deltaTime; Ray ray = new Ray(transform.position, (transform.rotation * Vector3.up)); Debug.DrawRay(ray.origin, ray.direction, Color.red); RaycastHit2D[] hits = Physics2D.RaycastAll(ray.origin.ToVector2(), ray.direction.ToVector2(), 0.0f); foreach (RaycastHit2D hit in hits) { if (hit.collider.gameObject == this.gameObject) { continue; } Ship ship = hit.collider.gameObject.GetComponent <Ship>(); if (ship != null && ship.Team != Team) { ShipMotor motor = hit.collider.gameObject.GetComponent <ShipMotor>(); if (motor.Destroyed) { break; } motor.Damage(Team, Damage); if (!Piercing) { Destroy(this.gameObject); } } } }