Behind the Scenes: The Perils of Camera Panning
Here’s a little insight into the kind of hard work that goes into make an Old Testament adventure game like Ebenezer. Today’s challege: camera panning.
A typical environment might look like this (this is the first scene – Kish and Saul’s farm at Gibeah):
But this environment is much wider than the screen of an iPhone, so the player will only see a tiny segment of this at any one point in time:
The aim then is to automatically pan the camera back and forth so that the player’s character remains visible on screen at all times. Roughly speaking, you want to wait until the player enters some fixed boundary around the edge to give yourself a bit of a headstart, rather than waiting until the player actually leaves the screen. Since the player was probably walking somewhere, you probably want to scroll a fair distance too, to let them see where they’re going. If all you did was maintain a fixed distance from the edge of the screen you’d feel very claustrophobic. So, once the camera starts to pan, I make it carry on moving until the player ends up about a third of the way from the opposite edge of the screen:
So far so good. But then we hit a snag: walking isn’t the only way that the player might end up too close to the edge of the screen. It can also happily naturally when the camera begins to zoom in on the scene. The last thing you want in this situation is for the camera to suddenly whizz off to one side – in this situation you really do just want to do the bare minimum to maintain a certain distance from the edge of the screen. The key is to make the code that looks after zooming the camera a bit smarter about which point it zooms in on – rather than always zooming in on the centre of the screen, it can pan as it zooms to keep the player’s position constant. As long as this adjustment is made before the main camera panning algorithm runs you should be fine:
It turns out to be a fairly simple solution in the end, but imagine a hundred such little decisions and you begin to see why developing a game takes a long time.
-
Categories
-
Articles
- July 2014
- June 2014
- January 2014
- March 2013
- March 2012
- February 2012
- January 2012
- October 2011
- August 2011
- July 2011
- June 2011
- April 2011
- March 2011
- February 2011
- January 2011
- December 2010
- November 2010
- June 2010
- May 2010
- April 2010
- March 2010
- February 2010
- December 2009
- October 2009
- August 2009
- July 2009
- June 2009
- May 2009
- March 2009
- February 2009
- January 2009
- November 2008
- August 2008
- March 2008
- January 2008
- December 2007
-
Meta