Help with parallax clouds

I have set up a simple parallax system with the following:
GML:
if (layer_exists("Mountains_BG_1"))
{
    layer_x("Mountains_BG_1",cam_x * 0.8);
}
I do this for multiple layers.
I have clouds that are a background layer that uses horizontal speed (in the room editor) to move.
I wanted to have the clouds have parallax but also move at the same time. When I apply the parallax code to the layer with a horizontal speed set, the clouds do not move.
It's probably a simple fix but I am not too sure how to do it since it's my first time with parallax.
 
You'll need an additional variable that keeps track of the "movement" of the clouds. Think of what's happening with the code:

1. The layer applies horizontal speed to x (It doesn't matter if this is the first step or the last).
2. The code resets x to cam_x * 0.8.

The horizontal speed doesn't matter, because x is always getting reset to whatever cam_x * 0.8 is.

So you'll need to keep track of the layer movement manually:

Create
Code:
mountain_x = 0;
Step
Code:
if (layer_exists("Mountains_BG_1"))
{
   mountain_x += 0.1; // This is your manual movement, set it to whatever you had in your room as horizontal speed
   layer_x("Mountains_BG_1",(cam_x * 0.8) + mountain_x);
}
 
Top