SOLVED how to get view xport and y when using camera_create

I followed the camera tutorial by Shaun Spalding

oCamera
create event
GML:
camera = camera_create();
var vm = matrix_build_lookat(x,y,-100,x,y,0,0,1,0);
var pm = matrix_build_projection_ortho(1366,768,2,-1000);

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

view_camera[0] = camera;

follow = oPlayer;
xTo = x;
yTo = y;
step event
GML:
x += (xTo -x)/25;
y += (yTo -y)/25;

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

var vm = matrix_build_lookat(x,y,-10,x,y,0,0,1,0);
camera_set_view_mat(camera, vm);
how do I get the x position/left position of the view?
 
Last edited:

gnysek

Member
camera_get_view_x(view_camera[0]) ? This needs to work as I'm using it in my game for 2 years already. If this doesn't work, then view or camera aren't properly assigned/enabled.
 
camera_get_view_x(view_camera[0]) ? This needs to work as I'm using it in my game for 2 years already. If this doesn't work, then view or camera aren't properly assigned/enabled.
so how do you set up your camera then? how does my code differ from yours?
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Camera_get_view_*** functions are only for cameras created using the camera_create_view() function. WHen building a camera using the matrix functions you need to use camera_get_view_mat() and then extract the position data from the matrix (which is a 16 value 1D array representing the 4x4 matrix, but don't ask me what it corresponds to as I have no idea, sorry! Experiment!).
 
Camera_get_view_*** functions are only for cameras created using the camera_create_view() function. WHen building a camera using the matrix functions you need to use camera_get_view_mat() and then extract the position data from the matrix (which is a 16 value 1D array representing the 4x4 matrix, but don't ask me what it corresponds to as I have no idea, sorry! Experiment!).
thank you! I played arround with it and its the 12 position I guess. but somehow it shows the only negative numbers so I wasnt sure if it really shows the values I am looking for

GML:
var mat =  camera_get_view_mat(camera);

show_debug_message(mat);
 
Top