I’ve seen a lot of questions regarding cameras, so I’m aiming to make this into a sort-of definitive guide for using them! Hence, if I’ve got something wrong or there are better ways of doing something, tell me in the comments and I’ll update it!

I will leave a (dd/mm/yy) formatted date here, so you know when this guide was last updated: 12/06/2020 (Added basic splitscreen/multiview set-up code)
I’ll also update the guide if there a better methods that I haven’t thought of/found out about yet, or if it turns out I’m using some function totally inappropriately.

GM Version: IDE: 2.2.4.451, RUNTIME: 2.2.4.357

Target Platforms: ALL

Download: Built Project

Summary:

This guide aims to give you a basic insight into the new camera system, and using it with views. Since cameras are totally new to GMS2, I’m going to write this from the PoV of someone very new to views, but also understands basic GML.

The included project, which uses information from all of these guides, looks like this:

Not spectacular, but demonstrates camera creation + assigning, view moving, zooming and interpolation.

The example controls for the project are simply “click to focus” and “scroll to zoom”

Relevant Documentation Links:

Tutorial:

Firstly, I’m going to point something out – you don’t actually need a camera to have a view – the room editor still has views which work in very much the same way as before. However, they are now far less flexible – you can no longer change view_[x,y,h,w]view through code anymore – unless you set up a camera to do more advanced tweaking.

If you are strictly no-code, then you will have to use the views with the room editor anyway, as there are no Drag&Drop camera functions currently.

Important things to know about this guide

  • I will be referring to “GameMaker Studio 2” as “GMS2” throughout the guide, because I am too lazy to keep writing it in full.
  • I’ll be going through cameras in GML – There are no D&D camera functions – so it helps if you understand code
  • If you want to know more about a function, or something is confusing you, remember to check the manual! You can find out more about most built-in functions, variables or constants by clicking on them in the code! It will open the relevant documentation page in a new tab.
  • If you have any other questions or corrections, please let me know!

Here are the things we’ll cover in this guide:

  1. Setting up a view (to use with cameras)
  2. Creating and deleting a Camera and Assigning cameras to views
  3. Setting a camera to follow an object through code (using the standard object tracking system)
  4. The other way to draw a camera without binding it to a view
  5. Camera scripts – update, begin and end
  6. Simple camera position interpolation
  7. Simple Camera Zooming
  8. Clamping the camera to the room bounds
  9. Other camera functions and what they do

 

From this point on, it’s all code!

 

 

 

 

 

 

 

 

 

So that’s that. That should be enough information to get you going with the new cameras, but if you need something more – some help, another guide with context – let me know, and I’ll see what I can do!