Some little things for today

I spent a few hours today adding some simple terrain up/down editor controls today, just to see how I feel about that. For those in the testing group, that will go out in 0.12.51 (hopefully tomorrow), and I’ll be interested to hear feedback.

(That’s just an image of some little hills and valleys I’ve quickly carved into regular field terrain)

But the bulk of the day went into (again) my own personal bugbear, the game camera. I’m sure I’ve mentioned before that I’m a bit finicky when it comes to camera behaviour, particularly in 3D games. I’ve specialised in it for most of my professional life, and I’d argue that for the vast majority of games, the camera is the second most important thing. (The first most important thing is sound. Third is probably art direction, and design comes in somewhere around fourth or lower).

Speaking broadly, I’m generally happy with MT2’s camera behaviour. It’s doing approximately the right things most of the time. But there are a few bad situations which can make it behave a little oddly. And this is because 3D tycoon game cameras are surprisingly tricky. To my mind, nobody’s figured them out yet. And some of them (I’ll point at the recently released Planet Coaster as an example) are so awful that it’d be almost laughable, if it wasn’t that it was fundamentally a really hard problem. (I suspect that Planet Coaster’s camera is so bad because they allow far more intricate terrain editing than most city builders do, and so they’re dealing with an even harder problem than the rest of us)

I have proven to myself, at least twice, that this Tycoon style of camera is fundamentally an unsolveable problem; that there’s no possible “perfect solution”, so I really shouldn’t waste time trying to find one.

But I keep gnawing at it, every couple of months. It feels like there ought to be a solution. But I just can’t make it work out.

Fundamentally, here’s the desired behaviour:

  1. The camera position is defined as an offset from a “focus position”. When the player “moves the camera”, they are actually moving that “focus position”, and the camera is just pulled along with it.
  2. The camera may be “zoomed” in and out (technically a dolly, not a zoom, but colloquially we call it zooming). This just adjusts the offset from the focus position to the camera, without moving the focus position itself. Many games will also change the camera’s angle as camera moves closer to the focus position. (As you get closer, you typically look more forward) MT2 does this, and lots of other 3D city builders do as well.
  3. When moving the camera while it’s far away from the ground, we mostly want it to glide horizontally, not move vertically. So even if the ground is undulating or bumpy, we want the camera to hold still and the terrain to undulate under it. When moving the camera while it’s close to the ground, though, we do want it to move up and down to follow the changing height of the terrain.

That’s the gist of the desired behaviour. It doesn’t sound like it should be hard to make a nice implementation of that. But the trap is in the requirements in part 3; since the camera’s position is based on the focus position, keeping the camera from moving vertically means keeping the focus position from moving vertically. And that in turn means that you’re not actually looking at and rotating around a point which is necessarily on the ground, but instead is normally an invisible point which is likely floating above or below the ground. And as you zoom in, you’re zooming in toward a point which is floating above or below the ground, not toward the ground itself. And there are a bunch of other problems around what to do if there’s high ground in between the focus point and the camera, such that the high ground is covering the middle of the screen, obscuring the focus point; should we rotate around the focus point, or around that high ground which is actually in the middle of the screen right now? And if the latter, then how do we avoid the camera deciding that we’re now closer to the focus point, and so changing its viewing angle?

It all becomes quite complicated quite quickly. But I’ve come up with a couple (I think?) clever ideas (mostly during the course of writing this post), and so those minor camera updates will be in the next build as well; interested in whether people stumble over any bad behaviour anywhere. Right now, I feel like it might be one of the best 3D tycoon game cameras I’ve seen. Which makes me a bit relieved to finally have something I’m generally happy with. :slight_smile: