• Register

Slinki is a hard-as-nails 2.5D action-platformer with a unique weapon - Use your own arm as a bladed projectile that always returns to you or push a button and propel yourself towards it instead. In the wake of the calamity that befell the forest he called home, strange things have happened to the small bunny known as Slinki. Changed, he must now rely on his mobility, your wit, and the boomerang-like bladed metal appendage that once used to be his arm, in his endeavour: To reach the sickened heart of his once peaceful Wood and end it's suffering.

Post feature Report RSS On 2.5D cameras (Part 2)

Making a good camera that behaves nicely was a lot more work than we anticipated but I think the results were worth it.

Posted by on

Well as promised here's what we're currently using. Many tweaks and variations were tried but in the end we figured out going back to "basics" was best.

That being said let's focus on the main point of a camera: Visibility. Our character should ALWAYS be visible. Easy enough to do right? Well you'd think so. Making a camera for a 2D game is easy enough, just move it along with the main character. Like so:


Unfortunately for us we decided to make a 2.5D platformer so there's yet another thing we haven't considered: our camera is slightly tilted downward! Simply following Slinki around would result in something like the following image. Say hello to the readers Slinki!

Ideally we want something like this.

There's a really easy way to fix this, you just have to keep the camera slightly above Slinki's position. While easy, this fix was too based on trial and error and we soon found out it was completely unreliable for keeping Slinki visible with varying monitor resolutions. We would have to do it the hard way.
Fortunately Unity has this amazing functionality that let's us project a ray from inside a "Screen" - an amazing function called

csharp code:
WorldToScreenPoint(Vector3 position);

In this image you can see 3 rays coming out from the "screen". The top one indicates things that will be at the leftmost corner, etc..

So now we can project a ray from the middle of the screen into the plane where Slinki is walking around normally. We get a point which is ideally where Slinki should be in our screen.

Now all we need to do is move the camera in a way that makes this imaginary point move towards Slinki's current position. Turns out Vector math WAS useful for something after all. My High school maths teacher would be proud.


What about our two previous points? Well Keeping slinki centred vertically in the middle of the screen actually worked out pretty nice. We just needed to make sure the camera was facing far back enough so we didn't lose track of the ground when the player performed the highest slingshot jumps.

As mentioned in the previous article we want to know where we're going. Keeping Slinki centred horizontally was pretty decent but as the player picked up speed this turned out to give us insufficient time to react to incoming threats. How to fix this?

  • We could zoom the camera further back, but this was going to be incredibly silly in practice
  • We tried making the camera try to place Slinki further right and left according to where the player is moving and his speed but this was quite difficult to tweak as sometimes the player just wanted to move left for a bit.

My friend and colleague Nuno says our game is starting to eerily resemble Sonic. Not wanting his suspicions to become unfounded I booted up Sonic CD and looked at how they did it.

Oh god what have I done
Oh god what have I done

It was amazingly simple. If the player moves left for a couple of seconds, shift sonic right, and vice versa. Otherwise, just keep him centred.This turned out to be exactly what we wanted: the player might be quickly moving left and right in a battle against either enemies or tricky platforming - showing more space left or right in these circumstances would be silly. By first checking if the player is keeping a certain direction for a few seconds we can be fairly sure he's not in such a situation.


Making a good camera that behaves nicely was a lot more work than we anticipated but I think the results were worth it. Here, have a celebratory .gif so you wash out my awful handwriting back there.


Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: