Megafuzz Dev Blog

Nerdy rants on programming and game design

Smoother Game Camera

You've Been Struck By... A Smooth Camera


A very fundamental, yet huge part of most games is moving around a world that is typically too big to fit into one screensize, and as such, the game needs a camera to follow the player. The simple solution is to do just that - make it follow the player character as soon as he or she moves. However, this isn't necessarily the most smooth or elegant solution. And since it's such a fundamental part of the game, let's see if we can do something to make it just a tiny bit nicer, should we?


This is how the camera movement used to look in Ronn For Your Life:



And this is how it looks now:





There's a couple of things that are different here. First off, the camera no longer instantly follows the player - instead, it sort of "catches up" but is always a tiny bit behind, both when he starts moving and when he stops moving. It's perceived as a less janky and more smooth visual experience - the slight delay is not enough that it feels like unresponsive controls, but it is enough that it feels like an overall smoother movement. This small deliberate lag of the camera is based on "lerping" - or linear interpolation. Instead of having the camera instantly move to the player's position whenever he moves, it slowly interpolates its current position over towards the player's position, and this is based on a "lerp value" that the player is able to turn up and down for both the horizontal and vertical camera movement. This means you could make it faster or slower than in the above example, and you could have it behave in different ways depending on whether it's moving left and right or up and down.


Another important little thing to note here, is that the player is no longer in the center of the screen when not moving. Rather, he will always automatically be sort of "peeking" towards whichever side he's currently pointed. It's a small thing, but it actually makes the experience a bit more immersive, because you're subconsciously focusing more on the side of the screen you're actually pointing towards.


Take a look at this example to see what I'm talking about:


Doing the same thing would have looked like this with the old camera system:


Not quite the same, is it?

You tell me which one is better - I definitely know what I think.

However, as I've talked about on previous blogposts, I genuinely believe in player choice and flexible settings above all, so if you for some reason actually would prefer the old cam system, then you can have that too. Like I mentioned earlier, you can change the level of camera "lerping", making it much slower or much faster. Or you can just disable lerping altogether - this will be a game option too, making the camera behave exactly like shown in the first GIF.

To showcase, here's an example of the new camera system but with the camera lerp value cranked up from a value of 0.1 to 0.25 - making for a much slower camera:



This is deliberately exaggerated for demonstration purposes, but the point is, you could actually make it behave like this (or even slower - or faster) - whatever you want. The camera is very flexible.


Just a quick example of how you can spend a little time making a very fundamental part of your game both look and feel much better - and with some very simple tricks and tweaks. And, as with everything as per my design philosophy - remember to give the player the option to disagree with me and my opinion on aesthetics by simply turning it off.