# Fake oblique projection

This is giving me some headscratch, I’m trying to achieve a 2D oblique projection as seen in games like Ultima VII or D&D Warriors of The Eternal Sun, creating the art isn’t a problem, my only problem is to manage the depth of the tile pieces, here an example from one of the games I mentioned:

And here some test assets I have created for my experiment:

It wouldn’t be a problem if I had to manage only Y, but in this case also X is a problem. Any idea or suggestion to how I can proceed to make characters going behind in front of walls in this kind of fake projection?

Use 3D and orthographic camera. Why torture yourself?

Because I want to use 2d art.

Of course, I understand. You can use quads and use your 2D. Just if you want to put a wall, rotate a quad as wall and setup camera as you need. It will be 2D, you will just cheat and it will be easy.

Just tried and see an example (you can see where the dog is, and no issues with depth and wall/ground is just 2d quads in 3d space:

PS: I just don’t know what camera angle you need though, but you should understand my point.

I understand what you are trying to suggest. By the way is topview camera that I’m doing. The problem is I’m using pixel art, using 3D geometry with textures in it won’t produce the same effect, just take a look at the walls angle of my temp assets in the screenshot, I want to maintain the pixelated aspect of the sprites thats why I’m having trouble with fake depth on 2d.

Ok. That makes sense. In this case you will need to do layering.
Lets say your graphics are in X/Z space and up/down is Y. Each layer will have different Y position.

Layer 1 - ground (Y= 0)
Layer 2 - colliders and units (Y=1)
Layer 3 - walls and structures (Y=2)

Now you will put your ground as layer 1 in Y = 0. Then you render all your units/similar in layer 2, which are above the ground (Y=1). And only then you render walls/etc which are on top of ground and units. This way when you walk with units you will be under wall.

The tricky part will be to setup colliders. If you want depth, you can’t have wall with full collider and your colliders must be in layer 2, same as units.

I painted an example for on top of that example. Maybe it will help you to understand a little bit better. (Blue- layer 1 (ground), green - layer 2 (colliders), red - layer 3 walls.

If you still don’t understand, I can make you an example if you give me some tiles (1 ground, 1 unit, 1 wall) because I’m not very good friends with painting stuff. Also, what unity version you are using.

I understand and that was my initial intention, but there is a problem, the parts covered by walls in the interiors can be walked on too. So for example take that house in the screenshot, when outside you can walk in front of the wall, but when inside the house you can walk behind the wall.

Probably this is best shown with a video, go around 5:30:

Also on the iron fence for example you can go both infront when on the right and behind when on the left, same goes for top. Is an annoying point of view to code in 2d, this I know, but I like it too much to just walk away for another solution.

By the way I’m using unity 4.3.2. There is another way I can solve it but require I change my artworkflow. I can make characters shorrter in height, and subdivide the wall section in two, lower part is always behind player and can’t be walked on by adding colliders, but upper part is always on top of everything, still I would have problems with door frames and also with taller characters.

But if you want to give a try, here the temp assets I did for the experiment: Imgur: The magic of the Internet

Just save the pic. Is supposed to be tiles of 16x16.

EDIT: In the end that last part I explained is what you are trying to tell me, so I kindda did the dumb smartass part lol.

Sorry for double post but here an update with a webplayer version of my test:

http://games.neuro-lab.net/resources/Webplayer/WebPlayer.html

Try entering the door. Basicly all I did is to subdivide the walls in two parts, bottom part is under the player layer (using sorting layers), while the upper part is above player, is all ok until you try enterin the door and can see where the problem start.

I was not able to try it out yet (a bit busy) but I can see you got the point. Your demo looks something that you want, right?

The only downside I can see is that it’s quite annoying approach of building the map. Some editor scripts might help here.

Yeah is the way I want, still gotta sort the upper wall parts, to build the maps is a pain but I’m already working on editor extensions for that, especially for colliders.

In the update method of your characters do this:
transform.Z = transform.X + transform.Y;
This will make sprites that are below and/or to the right render on top.

Edit: this assumes that the pivot point of your sprites is where the feet touch the ground.

I’m already doing this for characters, but I’m trying to avoid it on everything and find a more comfortable way to build scenes. I’m thinking that the only other solution is with z depth using a depth mask with custom shaders, pretty much like Pillars of Eternity.

In 2D mode you should not feel the difference assuming you have your script running in the editor and for static objects you put it in Start.
Of course it is not the nicest solution.