2D Mobile Game: Simple Parallax
In this article, I am going to cover how to create a simple parallax effect in a 2D game.
The Unity camera offers two options for project: Orthographic and Perspective. What is the difference? Perspective projection is how we see in the real world, where there is depth but Orthographic removes the depth.
The parallax effect us the sense of depth even in a 2D game, so we will take advantage of the Perspective Projection since this will allow us to give depth to the tilemap layers.
Now the Camera is in Perspective mode, we can add actual depth to the different tilemap layers.
The foreground layer we will put the depth at 0, making this layer the closet to the camera.
The background layer will have a depth of 1, being place as the 2nd furthest from the camera.
The far background will be at a depth of 3, putting it the furtherest away from the camera.
This image isn’t our game scene but it shows how we are giving each tilemap layer actual depth in our 2D space.
This shows an orthographic projection with no depth.
This is the perspective projection with different depth given to each layer. This makes the level more interesting and real even if it is 2D