Sunday, July 24, 2022
HomeGame Developmenttiles - Isometric ordering problem with transferring entities taller than one block

tiles – Isometric ordering problem with transferring entities taller than one block


Often we’d type objects by their floor place. In truth, we will argue there are two orders:

  • Kind objects by their floor place, again to entrance.
  • Kind object by their elevation, backside to high. That is sorting by stage.

And the primary one ought to take precedence. For instance, right here:

Character in front of stack of blocks, with some blocks behind drawn on top

The character must be in entrance of the entire stack that’s behind, due to its floor place. That is sorting by the SCREEN y place. For what I perceive the block exist in a xy grid, however these aren’t the display place, so I am not speaking about that y place. Additionally remember the fact that totally different ranges will end in a unique display y place. We wish the bottom stage. This is the reason I name it GROUND place. To be honest, I am calling it display y, it may be with out scaling (zoom) and translating (pan).

After all, on the stack, it’s best to draw what’s greater on high. That is sorting by stage.

I remind you that that you must observe the identical rule to place the character.


I assume you’d wish to put that on a single integer z-index. If the vary of excessive for the stacks we will try this simply: You’ll use multiples of the utmost stack measurement for the primary order, after which models for the second.

One thing like this:

zIndex = ScreenY * MaxStackSize + Stage

If you happen to view a spread of ranges (for instance, in case you slice the stacks for visibility), you can do it like this:

zIndex = ScreenY * (MaxLevel - MinLevel) + (Stage - MinLevel)

You may think about the characters to be on a stage greater than the ground it’s standing on.

Alternatively, you can think about the character to be on the identical stage, however make the block take even values for z-index (the computation above however multiplied by two), and the characters take the odd values (the computation above however multiplied by two and plus one). So characters and the blocks don’t compete for a slot.


In case you are doing this with Sprites in Godot you possibly can accomplish this through the use of the YSort node. Besides your stacked blocks ought to all have the identical place (so the YSort don’t type them), which you’ll accomplish with the offset property of the Sprite. And you’d nonetheless be answerable for sorting the stack.

In truth, I’d make all of the blocks of the stack little one of a single node… In order that YSort kinds these guardian nodes, and also you solely have to type the kids.

And since that you must observe the identical rule for the character, you’d use offset on the character sprite to vary the extent.

And you would need to compensate for that when positioning with the mouse. if the mouse pointer is on a high face of a block you possibly can put the character there, in any other case, you would need to put the character on one of many stacks which can be in entrance, and the character may need to be floating within the air to match the mouse pointer place.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments