• 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!

Multi Object Camera

T

ThePropagation

Guest
Hey I was looking for a smash brothers style camera where the camera zooms out when players move apart from one another and zoom back in when they get close. I found one and imported it into Studio 2 but I don't know how to make it be constrained to the room size. The new camera system is confusing to me and I don't know how to get it to work the way I want it to. I want the camera to zoom out unless the viewport is taller than the room height (or width, depending) and I'm not sure how to do it. And when i imported that Studio 1 project into Studio 2, it works, but the compatibility made the code awful and incomprehensible. Help!
 
T

ThePropagation

Guest
Here's the code for the multiple object tracking in game maker Studio 2.

if(!instance_exists(argument1)) exit;
camera_set_view_pos(view_get_camera(argument0), 0, 0);
with(argument1)
{
camera_set_view_pos(view_get_camera(argument0),
(camera_get_view_x(view_get_camera(argument0)) + x),
(camera_get_view_y(view_get_camera(argument0)) + y));
}
xDivide = camera_get_view_x(view_get_camera(argument0)) / instance_number(argument1);
yDivide = camera_get_view_y(view_get_camera(argument0)) / instance_number(argument1);
camera_set_view_pos(view_get_camera(argument0), xDivide, yDivide);
globalvar VMinX,VMaxX,VMinY,VMaxY;
VMinX = camera_get_view_x(view_get_camera(argument0));
VMaxX = camera_get_view_x(view_get_camera(argument0));
VMinY = camera_get_view_y(view_get_camera(argument0));
VMaxY = camera_get_view_y(view_get_camera(argument0));
with(argument1)
{
VMinX = min(VMinX, x);
VMaxX = max(VMaxX, x);
VMinY = min(VMinY, y);
VMaxY = max(VMaxY, y);
}
var VSize = max(argument2, (VMaxX-VMinX),
(VMaxY-VMinY) * (view_get_wport(view_get_camera(argument0))
/ view_get_hport(view_get_camera(argument0))));
Vwidth = VSize * (view_get_wport(view_get_camera(argument0)) / view_get_hport(view_get_camera(argument0)))
camera_set_view_size(view_get_camera(argument0), Vwidth, VSize);
centerX = camera_get_view_x(view_get_camera(argument0)) - (camera_get_view_width(view_get_camera(argument0)) / 2);
centerY = camera_get_view_y(view_get_camera(argument0)) - (camera_get_view_height(view_get_camera(argument0)) / 2);
camera_set_view_pos(view_get_camera(argument0), centerX, centerY);



What I want to do is figure out how to lock the camera onto the room height so that's the most zoomed out it will be. It zooms out, but it does it too much. Thanks
 
Last edited by a moderator:
Top