L
LanderMiskolczi
Guest
So i've been trying to get my buttons to follow the camera, and to do this, I need to get the camera x and y, but using the object it makes it lag behind. But when I use this function it only ever returns me a 0. Here's a gif to show you what I mean.
If you look to the left, that is printing out what the function is getting for the camera x and y. and I don't think it should be (0, 0) heres my camera code:
CREATE:
STEP:
The only reason the buttons are slightly following the camera, is because im having them follow the x and y of the object, but I know thats not optimal. Here is the button code:
CREATE:
STEP:
This is all I got. If you see anything wrong, please tell me, and if anyone knows whats going on with the function I would love to know. Thank you for reading this!
If you look to the left, that is printing out what the function is getting for the camera x and y. and I don't think it should be (0, 0) heres my camera code:
CREATE:
GML:
view_visible[0] = true;
view_enabled = true;
camera = camera_create();
var vm = matrix_build_lookat(x, y, -10, x, y, 0, 0, 1, 0);
var pm = matrix_build_projection_ortho(1024, 768, -1, 10000);
camera_set_view_mat(camera, vm);
camera_set_proj_mat(camera, pm);
view_camera[0] = camera;
follow = noone;
xTo = x;
yTo = y;
show_debug_message("(" + string(x) + " , " + string(y) + ")");
show_debug_message("(" + string(view_wport[0]) + " , " + string(view_hport[0]) + ")");
GML:
x += (xTo - x) / 25;
y += (yTo - y) / 25;
if follow != noone
{
xTo = follow.x;
yTo = follow.y;
}
x = clamp(x, 512, room_width-512);
y = clamp(y, 384, room_height-384);
var vm = matrix_build_lookat(x, y, -10, x, y, 0, 0, 1, 0);
camera_set_view_mat(camera, vm);
show_debug_message("(" + string(camera_get_view_x(view_camera[0])) + " , " + string(camera_get_view_y(view_camera[0])) + ")");
CREATE:
GML:
title = "ERROR";
text = "Button has received no information";
hotkey = "ERROR";
spell = false
spellSlot = "0";
xDiff = x - oGameController.cam.x;
yDiff = y - oGameController.cam.y;
show_debug_message("(" + string(x) + " , " + string(y) + ")");
show_debug_message("(" + string(camera_get_view_x(view_camera[0])) + " , " + string(camera_get_view_y(view_camera[0])) + ")");
show_debug_message("(" + string(xDiff) + " , " + string(yDiff) + ")");
GML:
cx = oGameController.cam.x;
cy = oGameController.cam.y;
x = cx + xDiff;
y = cy + yDiff;