Go to content Go to menu

It can be noted that I spend ample amounts of time caught in thought concerning trivial matters. Sometimes this can be seen as a rather keen attention to detail; a trait of value in matters of design.

More often than not though, it exhibits itself in the form of obsession concerning minutiae, of which this posts relates in the context of 2d camera systems.

A quick recollection of my favorite 2d platform games reveal to me that many cast the camera focus front-and-center upon the main player character unrelentingly tracking its movement pixel-per-pixel. Due to this the viewport, through which the player sees the world, adheres absolutely to the character in a 1-to-1 manner.

A slightly alternative method would be to borrow camera tracking as can be seen in films; a more organic and smooth method. It has been my observation that giving the camera the property of acceleration of its own, thus untying it from the strict movement of the character, gives the scene a much more cinematic feel. It gives the feeling of a camera-man trying to follow the actions of the main character, giving the player much more of a sense of dynamic movement. This idea isn’t at all original, I’m just wondering as to why the technique isn’t used more.

The way I go about achieving this is simple: Instead of applying newtonian physics to simulate organic movement of the camera, I simply apply the distance between the camera and the character as the velocity of the camera. This ensures that the camera moves fast when the character is far from centerscreen, slowing down as the camera draws a bead on the position of the character. It won’t over-shoot, so it won’t give the feeling of a camera-man franticly finding his target, but should give a smooth experience overall.

I will demonstrate the idea with the use of pseudo-pseudocode.

if CameraCenterX != CharacterX then
CameraCenterX = CameraCenterX – (CameraCenterX – CharacterX)

apply a velocity as a multiplicative factor to taste and of course the time delta to keep it framerate independent.

Instead of plain:

CameraCenterX = CharacterX

Of course, excuse any logic errors since I’m very tired. I might upload videos demonstrating this using the game engine that I’m currently writing (MAJOR work in progress) since it’s much easier to SEE it than to read about it.

1 Responses to "Pondering gamedesign minutiae: 2d camera tracking"

  1. Sparky Says:

    Hullo, I meandered here via your introductory post on TIGSource. This seems like an interesting type of camera movement, and I’d love to see it in motion. It also seems like it could be combined easily with other techniques.