Im developing a 2D game with some fake 3D effects (parallell projection). 2D-units are able to walk in front of buildings aswell as behind them, although themselves being just 2d-objects. This leads to a problem I will show you with a series of images (1-5). Can you tell me how to solve it?
Image 1: Animation for objects used in this example: Unit and Building.
Image 2: Unit and Building with animations and the physical bodies used in the game engine. Note the extruding arms and the building overhang enabling units to walk behind it.
Image 3: By using rendering order ground(0), units(1), buildings(2) the overall goal is reached. But as you can see the limbs of the unit is hidden by the building. This is my problem. How to solve it?
Image 4: I have tried splitting the building in a "front side" and a "back side" for rendering, but that leads to another issue - the corners. (Notice the penetrating hand on the rightmost unit.)
Image 5: So the final quick fix which I would rather avoid is this method: Enlarged buffered physical buildings and shortened unit limbs.
Please, what are youre ideas on how to solve the issues? If it matters, the game is continious and not built on grids or discrete values.