I don’t check for the edges, but define the allowed range of the center position. Even works at speed 200
Here’s my EnemyFormation.cs https://gist.github.com/guivho/678df454814b5f5285082a91c081db18
The width of the formation is a given, so the left and right max values for the formation center are available. When the center reaches the allowed edge, the direction can immediately be changed.