I’ve read plenty of answers as to how to approach a moving background when making a 2D game using Unity. My question though, is more targeted to the following type of game. Currently, I want to make a game where the player does move from left to right, and at the same time make the background move. So, is this still achieved with Parallax Scrolling, where I would only move the background if the player’s walk animation is played? and then if the player is in the idle animation, would the background stop? Or for this situation, is it valid to create a large static image in the background, and just have a camera following the player?
I’m not interested in how to code it, I’d just like to know what approach should be considered.
I’m fairly confident the effect should relate to the movement of the camera, not the player. Small difference, and maybe I’m wrong, but methinks it’ll look more natural if it’s determined by camera motion.
Create a quad which faces the camera. It can even be a child of the camera. Stretch the quad to fill the field-of-view. Place your background material on the quad. Write a script which changes the UV offset of the material based on camera movement. The scale of this offset delta determines the intensity of the parallax effect.
If using a single texture, either allow the texture to move so little the camera never observes a seam, or use a looping texture.
If you need multiple textures, the approach becomes considerably more complicated, and will involve multiple quads and some sneaky game design trickery known as “quilting” or “treadmilling”, where you physically move a group of textured quads around based on camera motion to maintain the illusion of a single seamless background; sort of like a patchwork quilt, where only the patches that can be observed exist in a given moment.