Old Testament Adventures » unity3d http://www.oldtestamentadventures.com Christian Video Games Done Right Sat, 26 Sep 2015 10:43:52 +0000 en-US hourly 1 http://wordpress.org/?v=4.3.4 Behind the Scenes: The Perils of Camera Panning http://www.oldtestamentadventures.com/2011/02/02/behind_the_scenes_the_perils_o/ http://www.oldtestamentadventures.com/2011/02/02/behind_the_scenes_the_perils_o/#comments Wed, 02 Feb 2011 14:43:42 +0000 http://localhost/otadventures/2011/02/02/behind_the_scenes_the_perils_o/ 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 [...]]]> 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):

panning0.png

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:

panning1.png

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:

panning2.png

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:

panning3.png

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.

]]> http://www.oldtestamentadventures.com/2011/02/02/behind_the_scenes_the_perils_o/feed/ 0