• Hey! Guest! The 40th (!!!) GMC Jam will take place between February 25th, 12:00 UTC to March 1st 12:00 UTC. Why not join in this very special anniversary jam! Click here to find out more!

GMS 2.3+ Scrolling Cloud Background Issue with Camera's position


Hey all, so I'm having a little trouble getting my horizontal speed to work correctly with my scrolling cloud background. Here is my chunk of code that controls parallex movement and cloud scrolling. The clouds move perfectly in regards to the speeds set for each background, that is until the camera starts moving in the horizontal direction left or right.

This line of code from the below code is what controls the cloud movement. layer_x(backgrounds[i,BGLAYERS.layer_id], x+ bg_scroll_speed_tracker); (with x representing the camera x position).

What's happening now is that when the camera moves, the camera's speed is offsetting the cloud speed by either adding or subtracting from it which is not correct. How do i set the cloud backgrounds on the layers to the viewport, and not relative to the camera so that the movement seems seemless.

Update: I should probably also mention that my cloud sprite is approximately 500x500 sprites tiled horizontally in the room.
   //Camera step event
//Handle background parralex effects and scrMovements for current stage
    for (i = 0; i < background_array_length; i++){
        if(layer_exists(backgrounds[i,BGLAYERS.layer_id])){ //Safety check
        //Create Parrallex effect based on offset values & auto scroll Movement based on hor speed values
        layer_x(backgrounds[i,BGLAYERS.layer_id],x / backgrounds[i,BGLAYERS.parralex_offset_x]);   
                if(backgrounds[i,BGLAYERS.scroll_speed_x] != 0)
                    bg_scroll_speed_tracker[i] -= backgrounds[i,BGLAYERS.scroll_speed_x]; //BG location tracker
                    layer_x(backgrounds[i,BGLAYERS.layer_id], x+ bg_scroll_speed_tracker[i]);   
                    //Reset Counter once background goes off screen so it doesn't go to infinity
                    if(bg_scroll_speed_tracker[i] <= backgrounds[i,BGLAYERS.sprite_w]){
                        bg_scroll_speed_tracker[i] += backgrounds[i,BGLAYERS.sprite_w];
Last edited: