• Hey! Guest! The 39th GMC Jam will take place between November 26th, 12:00 UTC and November 30th, 12:00 UTC. Why not join in! Click here to find out more!

GML [SOLVED] How to make the camera move whenever an object leaves the camera viewport?


In the game I Wanna Be The Guy, whenever you leave the screen, the camera instantly moves to the next screen. Here's a video as an example. (the best example is at 5:03)

What I'm trying to do is making it to whenever the player leaves the screen, the camera instantly shifts so that the next part of the room is showing, instead of having to make a new room for each screen.

I tried searching on the Internet for how to do that, but the only things I found were how to make the camera follow the player.

Does anyone know how to do this? Also, I'm using the Game Maker programming language, not drag and drop.

//camera create event
cam = view_camera[0];
view_width = camera_get_view_width(cam);
view_x = camera_get_view_x(cam);

//camera step event
if(Player.x > view_x + view_width) view_x += view_width;

(if there's a special code block you can use when creating threads on this website, please tell me. I'm new to these forums)