How to make side scroller camera like Playdead's Inside?

How would you script a camera like the one from Inside?

Guessing it goes on a spline parallel with a spline the character’s on, but how does it move independently of the character, sometimes moving farther left and sometimes farther right than the character? The camera can also move in or out at certain points as the character walks forward, and the camera movement is reversed if the character walks backward.

Here’s a link to a walkthrough of Inside on YouTube. Skip to 1:00 to see the types of camera movements I’m talking about.

Thanks!

Played the game a couple of times. The camera work is quite elegant indeed.

Not sure if it’s a spline, somehow I doubt it. Hooking it up to a spline would be quite rigid unless you wanted to deform the spline and calculate the tangents - probably too fussy. I might be wrong, though.


I’d approach it by creating a standalone actor with a camera on a springarm - its length being the distance, and relative rotation the angle. The camera actor would need to track-interpolate several elements simultaneously:

  • player velocity vector
  • looking direction
  • a point of interest (most likely a camera-exclusive collision volume)
  • that one thing that I did not think about when creating it so now I need to rewrite half of the code…

Every Tick you’d construct a final resting position vector for the camera and interpolate location and rotation to match it. This will require quite a bit of tweaking to get the result you need. I’d probably make the interpolation rate dynamic as well so you have the ability to make the camera smoothing tighter when the action gets tense. For something as fine-tuned as this, I’d forgo the built-in camera lag completely and relay on custom functionality.

I believe this could be a start. Does this help at all?

Thanks for your reply!

If I understand, a camera on a springarm and collision volumes for adding camera movements independently of the character would definitely work, but the more camera movements there are, the more coding that would need to be done per movement, right?

There are so many unique camera movements in Inside, I’m guessing they wouldn’t have used collision volumes for all of them. Came up with a spline-based system this morning that seems like it would work without collision volumes, but don’t know how to implement it.

Think of a character spline and a camera spline next to each other, each spline having an equal number of spline points. If the character moves from its current spline point to the next spline point, the camera also moves from its current spline point to its next spline point. Basically, when the character reaches the next spline point, the camera also needs to reach the next spline point. If the character is halfway between the previous spline point and the next spline point, the camera is told it also needs to be halfway between its own previous spline point and the next spline point. It doesn’t matter how different the physical shapes of the splines actually are, all the camera needs to know is what percentage of the distance between the previous spline point and the next spline point it needs to be at.

This would allow the camera to be able to move in the ways I’m talking about, but don’t know how to script something like this. Any ideas?

Thanks again!

1 Like

Here’s a quick mock-up of how it could work, this is not exactly what you’re asking (time constraints today!) but I’ll try to have a closer look at it, tomorrow perhaps.

Atm, it just tries to find the closest point on the camera spline and position the camera between the player and that point:

Image from Gyazo

The white dot is the camera’s desired location, the orange is the closest point on the camera’s spline.

This is far from perfect when the spline is tense or tangled (at seen here) but works well when the spline flows more naturally. Mapping spline length onto another spline would require a bit more work, though but should be perfectly doable.

2 Likes

Yesterday I made a basic project where I implemented the solution I originally mentioned just to demo how I imagined it could work:

Image from Gyazo

  • the white cone is an object with a collision volume
  • the cone object contains data defining camera modifiers in this area
  • when the player’s collision volume interacts with that volume, the camera modifiers are added to the regular camera logic, the modifiers are removed when you leave the area
  • the effects are cumulative so numerous modifiers can be active at the same time; atm the system accumulates simple values and the camera actor behaves according to those rules

Things are somewhat hard-coded; if I were to turn into a smart(ish) camera system, I’d base it around Actor Components getting dynamically added to the camera actor, each bringing a new set of rules. This would provide a lot of granular fidelity as each component can define complex logic.

A camera would sit, gather info about its components and act accordingly. This would be a useful system for all things unpredictable and procedural, where you do not know what’s behind the corner but the camera can cleverly pick up on it.

Again it all depends on the desired effect and could be combined with the spline method you need.

2 Likes

Really like this idea. Any plans to put it on the marketplace? Far as I can see, there’s nothing like this out there.

@Everynone Sorry for poking in such an old thread but this looks great. Did you ever release it on the Marketplace? Or would you mind telling me a bit more how you did it? You don’t have to show the code I’m just curious since I would like to implement something similar myself.

Assuming you’re talking about the most recent post of mine above, the description is in the bullet point format. Not really much more to it.

implement something similar

Which part are you having issues with specifically?