1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

GMS 2 Camera's Position

Discussion in 'Programming' started by CloseRange, Sep 25, 2019.

  1. CloseRange

    CloseRange Member

    Joined:
    Jul 2, 2016
    Posts:
    858
    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.
     
  2. samspade

    samspade Member

    Joined:
    Feb 26, 2017
    Posts:
    2,061
    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 likes this.
  3. CloseRange

    CloseRange Member

    Joined:
    Jul 2, 2016
    Posts:
    858
    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
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice