GameMaker Camera doesnt move

Z

zendraw

Guest
this is supposed to move the camera, but it doesnt move it for whatever reason.

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

GMWolf

aka fel666
Is your x and y changing?
Is your camera being applied?
Make sure your Z from is correct according to GM depth. I may be wrong but off the top of my head Z should be positive, and look in the -z direction for a "top down" perspective.

Also the docs show it being used with a projection matrix, but afaik that shouldn't be an issue.
 
Z

zendraw

Guest
im following this tutorial, all the code is pretty much the same, checkd multiple times. it works for him apperantly but not for me, the moving part.
-x and y are changing
-what do you mean?
-ill see about this.
 

samspade

Member
this is supposed to move the camera, but it doesnt move it for whatever reason.

GML:
var vm=matrix_build_lookat(x, y, -10, x, y, 0, 0, 1, 0);
camera_set_view_mat(global.camera, vm);
I'd also strongly recommend never using the matrix camera version. I used to and when I switched over to the built in camera functions, life became so, so much easier and so far I haven't found anything you can't do with them (at least in 2D).

 
Z

zendraw

Guest
that pope video is too old and outdated. and the methods in it are supre ineffective.
 

GMWolf

aka fel666
yeah so view_camera[0] is set to global.camera
do you have a view 0? if you don't have views enabled then it wont work.

that pope video is too old and outdated. and the methods in it are supre ineffective.
It looks perfectly reasonable to me, and if all you are doing is setting the position and size of your view then using the camera functions makes a lot more sense than building the matrices yourself.
I wouldnt call something "ineffective" if you can't get your version to work haha


that pope video is too old and outdated.
The pope video is more recent than the shaun tutorial too...
 

samspade

Member
that pope video is too old and outdated. and the methods in it are supre ineffective.
The one you're using is older though? It is also difficult to get right, takes more code, doesn't play well with some of the other GM functions, and provides no advantages (as far as I know) in 2d. That said, I used it for a year or so before I converted, so you can use it.
 
Z

zendraw

Guest
dude, i can move the camera fine with camera_set_view_pos function, everything is done, its just for some reason it doesnt work with these metrics functions.

the way views and stuff are now in gm2, the only non problematic way i see for doing cameras right is creating them. and that is what shaun is doing, thats why i watch what he does. pope`s tutorial is messy, he uses the inbuilt one, not to mention he sets the camera size every frame in end step event. its super messy and problematic in the long run. if you dont see a problem with setting camera size every frame, what can i say... shaun`s video is older but its better. its just bizzare why it doesnt work for me.
 

samspade

Member
dude, i can move the camera fine with camera_set_view_pos function, everything is done, its just for some reason it doesnt work with these metrics functions.

the way views and stuff are now in gm2, the only non problematic way i see for doing cameras right is creating them. and that is what shaun is doing, thats why i watch what he does. pope`s tutorial is messy, he uses the inbuilt one, not to mention he sets the camera size every frame in end step event. its super messy and problematic in the long run. if you dont see a problem with setting camera size every frame, what can i say... shaun`s video is older but its better. its just bizzare why it doesnt work for me.
I'm not saying you have to use the built-in functions, I'm just saying that I've used both and the built in one is much easier. My entire camera controller code is generally about few lines long. Only 1-2 of those in the step event (you only set the camera size every frame if you want to. If you don't want to, you can omit that line (which I believe he says in the video)). And so far, I haven't found anything the built in functions can't do faster and with fewer lines of code than the matrix version (which again, I used for over a year).

Also, if I remember correctly, you can't use the camera_get_* functions with custom cameras (this might have changed, it's been years since I used one) and remember that if you are creating your own camera, you need to manage their destruction as well. These can cause issues as well if you are creating custom cameras (as how you reference them may or may not be changing as expected).
 
Top