• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker Camera's Position

CloseRange

Member
I've started to try and figure out game maker 2's camera system and I thought I had it down but I can't do something as simple as getting the camera's position....
Code:
x = 250;
y = 250;

var cam = camera_create();
var vm = matrix_build_lookat(x, y, -10, x, y, 0, 0, 1, 0);
var pm = matrix_build_projection_ortho(640, 480, 1, 1000000);

camera_set_view_mat(cam, vm);
camera_set_proj_mat(cam, pm);
view_camera[0] = cam;

show_message(camera_get_view_x(view_camera[0]));
i'd expect it to show me the message "250" as that should be the camera's x position, however it still only shows me '0'

I tried adding camera_apply(cam); before i got the position but still, nothing.
 

samspade

Member
I've started to try and figure out game maker 2's camera system and I thought I had it down but I can't do something as simple as getting the camera's position....
Code:
x = 250;
y = 250;

var cam = camera_create();
var vm = matrix_build_lookat(x, y, -10, x, y, 0, 0, 1, 0);
var pm = matrix_build_projection_ortho(640, 480, 1, 1000000);

camera_set_view_mat(cam, vm);
camera_set_proj_mat(cam, pm);
view_camera[0] = cam;

show_message(camera_get_view_x(view_camera[0]));
i'd expect it to show me the message "250" as that should be the camera's x position, however it still only shows me '0'

I tried adding camera_apply(cam); before i got the position but still, nothing.
I'm not sure if the camera_get_view functions work on custom cameras. I seem to remember something like that and when I used custom cameras always having to use the view functions directly instead. I can't remember for sure because its been awhile since used the matrix system.

Personally, I wouldn't use the matrix option at all unless you know you need it for some reason. I would just use the built in functions. See this tutorial:


Don't use the room editor and be careful with some of them like auto following which has unchangable restrictions (such as not being able to leave the room) but for the most part they all work exactly as expected and are much simpler to use, debug, and not make mistakes with.
 

CloseRange

Member
I'm not sure if the camera_get_view functions work on custom cameras. I seem to remember something like that and when I used custom cameras always having to use the view functions directly instead. I can't remember for sure because its been awhile since used the matrix system.

Personally, I wouldn't use the matrix option at all unless you know you need it for some reason. I would just use the built in functions. See this tutorial:


Don't use the room editor and be careful with some of them like auto following which has unchangable restrictions (such as not being able to leave the room) but for the most part they all work exactly as expected and are much simpler to use, debug, and not make mistakes with.
Thank you! that was actually very helpful. I still feel like there is a lot more that can be done with cameras, but I'll wait till I can actually work with them before attempting anything crazy
 
Top