Keeping Up — A Smarter Camera For Munch Time 2

As you can see in the above trailer, Munch Time 2 is a 2D metroidvania platformer with a focus on active combat and swing physics, that all come together in a light puzzle-filled adventure about a silly little chameleon called Munch. We recently redesigned the camera system for MT2, so here’s how (and why).

Munch Time necessitates an active camera because of limited screen real-estate (especially on phones) and because lots of the character’s abilities are powered by the environment (outside-in), as opposed to the character (inside-out).

In the first Munch Time the camera is pretty simple:

It takes all relevant interactable objects and platforms, and finds the largest acceptable rectangle (at the current aspect ratio) that encompasses them all. To ensure we always see the most important things first, all objects are given a priority, and lower priorities get cut first. This is updated every .5 seconds or so.

Whereas MT1 had very little moving elements, in MT2 pretty much everything moves. Munch can move around rather quickly, gaining all sorts of traversal abilities; some of which aren’t bound to external objects, such as dash.

When we applied the original camera to this new environment, it went absolutely nuts. The update frequency was too low, and the constant movement would mean either zooming out incredibly far all the time, or zipping around constantly. Since none of that was acceptable, we rewrote the whole thing.

The basic idea remains the same: the camera processes Munch’s environment, finds things that you should be able to see, and makes sure you can. That alone is made more difficult by the more complex possibility space, but it also needs to keep track of character velocity and keep motion to a minimum whenever possible.

Our current approach is as follows (a lot of this information is eased over time):

  • Get a list of camera targets (flowers, enemies, platforms within jumping height, etc.), from a relatively small range (max 110% use range), and make sure only the things we can actively employ are taken into account (i.e. things behind walls should be ignored)
  • Add additional high priority targets for character movement (which is a combination of direct translation, physical velocity and displacement by moving platforms), limited by environment collision.
  • Get a centered rectangle for these points. If it’s too large for the current view, zoom out. Basically the points have a tug-of-war with the camera position, and if they pull it in opposite directions it scales instead.
  • Add offsets for situational stuff, such as when Munch is drifting from a flower (its velocity is added to final target).
  • Check and modify this final desired position using a screen rectangle for the main character, which moves around based on the character’s velocity.
  • Handle camera’s collision with specific areas by either gently pushing it out, or stopping it from intersecting at all (level exits), then apply position. Note this happens after keeping the character on-screen, so Munch can still walk off-screen for transitions.
  • Ease-apply orthographic size; more quickly when zooming out than in, because that’s crucial to game play.

Here’s some WIP footage, including debug gizmos. Check if you can recognize some of the above happening:

Aaron Oostdijk (Gamistry)
Aaron Oostdijk (Gamistry)
Aaron Oostdijk is lead programmer for Gamistry, that he co-founded with four classmates from Game Design & Development (HKU) in 2009. Over the years he's specialized in mobile games, but is now also working on projects that are moving to other platforms. The first of hopefully many games of this kind is Munch Time 2, a 2D metroidvania platformer that's been in development since early 2014.

Related articles