Parallax on Instance Layer

Whats up gang! Obligatory "I am new to GML", but I have a question that I am hoping there is a simple answer for. I am setting up Parallaxing for my Side Scroller Game and it works great for the "Background Layers" but I want to also be able to apply it to Standard Instance layers. The code that works for the BG layers does not for the others. How can I get this to work for them as well?

(Camera) Create Event
P1 = layer_get_id("P_L1");
(Camera) Step Event
if (P1) layer_x(P1,x/2);


Friendly Tyrant
Forum Staff
This is an issue with naming of the layer functions (something I've flagged as a bug and believe will be getting updated in the future). The layer_x functions ONLY affect background elements on the layer, so the code above won't work for instances. Afaik, the only way to do what you want would be to get all the elements on a layer, then loop through them checking their type to see if they are instances (if the layer ONLY contains instances then this won't be necessary) and then add/subtract from their x/y coords manually.

So, something like:

var a = layer_get_all_elements(layer_ID);
for (var i = 0; i < array_length_1d(a); i++;)
   with (a[i])
        x = other.x / 2; // or whatever... :)