So I've been scratching my head at this problem for over a week now, and would love some insight from anyone who might know a bit more.

In my game I have the floor flat on the X/Z plane with walls/characters rotated +45 degrees about the X axis. The orthographic camera is pointing down also at 45 degrees about the x axis, parallel with my walls/characters: enter image description here

As a result, I dont see any distortion for players/characters since they face the camera directly on, while the ground however sees a distortion of sqrt(2) shorter. This makes sense considering how an orthographic camera works. To fix this, I've made my Tilemap set up with X:1 Y:1 Z:Sqrt(2) so that each tile is stretched on the Z axis by Sqrt(2) to compensate for this distortion.

All looks well with only one problem now... foreshortening with regards to movement: Forward and backwards movements of objects/characters along the z axis are perceived to be slower than movements left/right on the x axis. This makes sense because while each tile is perceived to be a square in the camera view thanks to scaling Z on the tilemap by sqrt(2), the real world tile is, well, sqrt(2) times taller than its width, so obviously it takes longer to travel forwards / backwards.

I've found another post here that also touches on this: How to handle forward/backward movement in an oblique top-down view

Now looking at this thread: https://www.reddit.com/r/EnterTheGungeon/comments/4sed7a/developers_how_did_you_get_into_programming_and/d7p3jjv/?utm_source=share&utm_medium=web2x

It seems to me that DodgeRollBrent is describing almost an identical setup in their game, Enter the Gungeon, with the minor exception that their camera is facing directly along the z axis and the floor and walls are rotated +45/-45 instead. And yes they choose to also scale their walls/characters by sqrt(2) as they're parallel with the floor.

I think the part where I'm particularly confused is where the user HubT initially asks:

I mean if I create an orthographic camera and tilt it by 45 degrees the sqrt(2) distorted walls (the walls have Z depth and are perpendicular to the ground) align up nicely but the ground gets distorted (obviously). So I distort the ground tiles by sqrt(2) but this essentially stretches the ground by 40% so every vertical movement now has to be increased by 40%.

And DodgeRollBrent responds with:

so the walls are tilted 45 degrees toward the camera, and the floors are tilted 45 degrees away from the camera, meaning that each should experience sqrt(2) distortion because of the additional length along the z-axis

however, the vertical (y-axis) floor length shouldn't be perceptually changed. i think it sounds like the element you're missing is that the ground is tilted with respect to the camera as well.

So it looks like indeed their camera is facing the floor at an angle, but from what they've described they don't seem to be having the foreshortening problem that both me and the other user have described (movement being slowed down by ~40%).

My summed up question:

What does he mean by:

the vertical (y-axis) floor length shouldn't be perceptually changed.

This seems to contradict what they say about the 45 degree angled floor / both the floor/walls being distorted by sqrt(2).

I would love someone else's interpretation of all this. If I have an orthographic camera facing the floor at an angle as I've pictured above, are my only two options to fix foreshortened movement (based on the other question on gamedev stack exchange linked above) to either:

  1. Amend vertical movement to be faster (would it be as simple as setting the z component of the velocity to be sqrt(2) times faster?)

  2. Set up my camera to be "Oblique" with a scale set to the z - axis (As mentioned here: How to handle forward/backward movement in an oblique top-down view)

Or is there another way of solving this? I'm very wary of changing the vertical speed as I can very well see some knockons of this in the other systems of my game.

I'm also a bit worried about messing around with the projection matrix. Just from testing using this script provided here: https://github.com/keijiro/unity-oblique-projection I'm having some confusion understanding what the z scale should be in my case, and also why the camera seems to get offset when I set the z scale (although I'll save these questions maybe for another post since this one is plenty long now).

If you've read through this, thank you. Any help with this would be massively appreciated.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.