TransWikia.com

Render order in 3/4 view game

Game Development Asked by Chuan Li on January 10, 2021

I’m writing a 2D game with an internal 3D space. The view is 3/4 view. I’ve run into trouble with the render order of entites.

Context: The world uses a tile system, like a 3 dimensional lattice, each tile is a 1x1x1 space. Entities have a 3D coordinate position and do not snap to tiles(may straddle two tiles). Entities have their own width, height, and depth, all entities are strictly oblongs and do not rotate(only exist in right angles). Since the view angle is fixed and there is no perspective, the graphical representation of the tiles and entities are all 2D images(they are all sprites)

Question: How do I code for render orders in a 3/4 view?

So far, I’ve defined the render order using the y and z coordinate of the entity(I believe x coordinate is irrelevant in 3/4 view). However, it quickly dawned how using a single point to define the layer of an entity with a height and depth was bound to have issues. This is illustrated in the following image:
enter image description here
The horizontal axis is y, while the vertical axis is z. The dashed line represents the view angle.

The blue box and green box should be rendered above the red box. However, when the render order is determined by either the y or the z coordinate of the entity’s origin point(highlighted), it is impossible for the system to be consistant.

For instance, if the renderer renders from lowest to highest(layer based on z coordinate), the red box would cover the green box, which is incorrect. If the render renders from back to front(layer based on y coordinate), the red box would appear on top of the blue box, which is incorrect. A mixture of y and z coordinate(e.g. y + z = layer) would be inconsistant also, though it does agree with the example shown.

Without assumptions about the features of the game I am creating, is there a way to have a system that can consistantly order render layers correctly, given information of 3D coordinate position and dimensions of all entities? Also given that each entity is represented as a flat, 2D sprite?

I have encountered numerous sites warning people away from 3D, since it is "orders of magnitude" harder than 2D. Could I walk the tightrope and introduce some 3D elements to solve this issue, while keeping the game 2D and in 3/4 view angle? Thanks in advance.

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP