Camera and layers

Hi !
I am working on a simple platform game. I used a camera as in the example “Alien-World” which moves behind the hero. I have several layers of background, which speed is controlled in the camera script (parallax effect).

However, I do not know how to make the farthest background layer was always in the same place (was stationary). How to achieve it ?

Hi @Jerry80 !

The effect you’re looking for is called “parallax effect”.
If you’re currently moving the ground based on the players movement, you should also move the parallax layer based on the same movement and also the distance from the camera.

local move_x = base_move_x / z_dist

This code is just an example, but gives you an idea of what’s going on.
(I suspect there are many articles out there that explains it better than me)

2 Likes

Thank you, I will try