I am currently developing a 2D endless runner game. One of the obstacles are rockets flying from the right edge of the screen to the left. The missiles spawn outside the camera view and move constantly to the left on the x-axis. As long as the missiles are outside the camera view they should behave as shown in the picture. The rockets follow the y-position of the player in a slowed way. The y-position of the rocket closest to the player’s y-position should follow the player’s y-position. The other rockets should then each be positioned with a slightly offset y-position above/below the player’s y-position. So if the player moves up/down the missile that is targeted directly at the players y-position can change. If a missile reaches the edge of the screen, it should not change its y-position anymore and is no longer considered for the behavior described above.
If my description is unclear or there are any other areas of confusion, I will try to add to explanations as best I can.
Thanks for any ideas how I could implement this behavior.