Comments

Log in with itch.io to leave a comment.

Ysort and stuff related has become so much easier with the Layers in 4.
I just stumbled on this, looking up Godot content.
For other stumblers:
in Godot 4.2, you can make Layers to a TileMap, name them anything like Ground, Cliff, ysort... and make ysort assets on the ysort layer.
So, Ground[LV1] can be like floor tiles, small plants, anything you can walk over.
No worry on collision layers, just floor art.  
Cliff/Wall [LV2] can be anything you want to put a collision on, like a wall or cliff. Example, you can't walk up a cliff, so make a collision on cliff or wall tiles. But, you want to be able to be able to walk on top a cliff area/behind a wall, so just collision on that layer of the proper tiles.
ysort [LV3] is where it gets fun/complicated:
You put any tile assets, that you want ysorting on, in this layer.
Grass, flowers, floor, stays on LV1.
Lv2: Front facing Cliffs, front facing walls, you give a collision shape, and only them.
Lv3:
Trees, crates, backside of cliffs/walls, ect, you single out those assets, add a Physics layer, collision, Ysort origin, on those.   

Wow! looks great! Metal Gear solid feel :)

I'm just starting using Godot, could you please tell me how you implemented hiding behind boxes? 

Do you change player's Z position when the player crosses some Y position?

Oh dear, sorry I've only just seen this. If you or anyone else needs to know:
I have a YSort node, with two children: The TileMap with all the objects like the boxes, and the Player. I don't think I did anything special to the tilemap or the tiles themselves... make sure that in your TileMap node, you set the Tile Origin correctly to either center or bottom. I haven't looked at this project or Godot in a while!

Thank you for reply! :) 

Could you please explain what YSort node does here? What is the logic?


(2 edits)

All children of a YSort node will be displayed in a particular order, based on their y positions. Child nodes with a higher y position will appear on top of nodes with a lower y position. So rather than using Godot's default "Z index", or level hierarchy to determine what goes on top of something else, it's using the y position of each object - things lower on the screen will be in front!

So when the player's origin point is below the box's origin point, that means the player should appear in front of the boxes. Once you move the player up so that their origin point is above the boxes' origin point, the boxes will be drawn on top instead.

Note that for this type of game, each object's origin point should be set to "bottom", at the point where they "touch the ground". Having it set in the middle of the object can lead to weird results.

Oh Wow! Thank you so much for such a precious piece of information! :)

Hey that's pretty neat. You got something done. There's a lot of cool systems in play here.

Thanks!