I’m working on a Paper2D “infinite sidescroller running” game. I have static sky sprite for the background at around -500 Y, a ground sprite at 0 Y, and the player runs in place on the ground at 0 Y.
Movement is simulated by spawning actors off screen to the right that then have Projectile movment applied in the -X direction. These consist of:
obstacles: 0 Y so that the player has to jump over them
collectibles: 0 Y so the player can collect them
near background objects: -200 Y so that they pass unaffected behind the player, obstacles, and collectibles
far background objects: -400 Y so that they pass behind the near background but in front of the sky
I use functions to spawn the actors from classes and add projectile movement, and timers on the Character BP to have them spawn at random floats within ranges (except for the buildings, which iterate from the array in index order and then restart after reaching the end). The sprites attached to the actors are restricted to the xz plane, and the functions that spawn them also add a “Set Plane Constraint Axis Setting” of Y in further efforts to keep them in their proper Y positions.
The far and near background actor sprites are set to have no collision. The obstacles and collectibles are set to overlap with the player.
The issue is that as the actors move across the screen, the background objects will sometimes temporarily be “in front” of the foreground objects, sometimes starting in front and then moving behind and sometimes starting where they should be and then moving in front before reverting once more.
I assume this is happening on tick and maybe has something to do with the functions/timers not getting the Y location information in a timely fashion? (I’m just making stuff up, I have no idea, really.)