Playing around with spawning random objects to go with my new scrolling background technique. I have a collection of different objects the player is going to have to jump over while they try to escape from the zombies. As you can see I have each object randomly picking from an array of sprites, scrolling in sync with the floor texture and disappearing when going out of the camera’s view.
Here you can see how the layers are working (I exaggerated the Z index of the ground to make it easier to see.
Basically, I have a spawner offscreen and it’s aligned with the ground. Each of the objects has a Rigidbody2D and when it’s created I simply apply a constant force to it so it move in sync with the ground animation.
One last thing, I noticed some bad stuttering when the objects scrolled across the screen. To fix this I set the Interpolate setting on the prefab’s Rigidbody2D component in the Inspector.