Parallax scrolling stopped when using Spaldings "Smooth Camera Tutorial"

I posted this question here but it seems it didn't get any attention. So I'm posting it here on its own instead.

My parallax stopped working when I changed camera.

My parallax code is in it's own object in the step event:

GML:
var cam_x = camera_get_view_x(view_camera[0]);
var cam_y = camera_get_view_y(view_camera[0]);

layer_x("Parallax_01", cam_x * 0.25);
layer_y("Parallax_01", cam_y * 0.25);
It worked fine when I used the regular camera and object following my player object, but I recently switch to Spaldings "Smooth Camera Tutorial" and it stopped working. I can't seem to figure out what I should change for it to work.

Spalding style camera object:

Create
GML:
camera = camera_create();

var vm = matrix_build_lookat(x, y, -10, x, y, 0, 0,1,0);
var pm = matrix_build_projection_ortho(640, 360, 1, 10000);

camera_set_view_mat(camera, vm);
camera_set_proj_mat(camera, pm);

view_camera[0] = camera;

follow = obj_player;

xTo = x;
yTo = y;
Step:

GML:
x += (xTo - x)/5;
y += (yTo - y)/5;

if (follow != noone)
{
    xTo = follow.x;
    yTo = follow.y - 50;
}

var vm = matrix_build_lookat(x, y, -10, x, y, 0, 0, 1, 0);
camera_set_view_mat(camera, vm);
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Moderator
I'm pretty sure that the camera stuff goes through a different pipeline when you start to use matrices to set the camera properties in this way, so you'll need to stop using camera_get_view_x/y and extract those values from the created camera matrix instead.
 
I'm pretty sure that the camera stuff goes through a different pipeline when you start to use matrices to set the camera properties in this way, so you'll need to stop using camera_get_view_x/y and extract those values from the created camera matrix instead.
Ok, erm, how would one go about doing that? I've tried camera_get_view_x(obj_camera.camera); instead of camera_get_view_x(view_camera[0]); but it still didn't work.

EDIT:

OMG, never mind, I guess I understood as I wrote it out. i fixed it with:

GML:
layer_x("Parallax_01", obj_camera.x * 0.25);
layer_y("Parallax_01", obj_camera.y * 0.25);
Thank you!
 
Top