protected override void UpdateCast() { var position = CachedTransform.position; var rotation = CachedTransform.eulerAngles; var scale = CachedTransform.lossyScale; float angleIncrement = 0f; if (Amount > 1) { angleIncrement = Spread / (Amount - 1); rotation.z -= Spread / 2f; } for (int i = 0; i < Amount; i++) { Vector2 direction = Quaternion.Euler(rotation) * Vector2.right; direction.Scale(scale); RaycastHit2D hit; if (Draw && Application.isEditor) { Debug.DrawRay(position, direction * Distance, Color.green); } switch (HitMode) { case RaycastHitModes.First: hit = Physics2D.Raycast(position, direction, Distance, Mask); if (hit.collider != null) { Hits.Add(hit); return; } break; case RaycastHitModes.FirstOfEach: hit = Physics2D.Raycast(position, direction, Distance, Mask); if (hit.collider != null) { Hits.Add(hit); } break; case RaycastHitModes.All: Hits.AddRange(Physics2D.RaycastAll(position, direction, Distance, Mask)); break; } rotation.z += angleIncrement; } }