Why do you have to parent a node to a TileMap in order for its "YSort" to work in an Isometric Game?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By bodicpen

In the Godot Engine demo title “Isometric Game” where you’re in a dungeon and your player is a troll, I’ve noticed that the Player had to be a child of the walls tilemap for its YSort to work. Putting both the tilemap and the Player under a YSort parent node would not have the same results.

Basically the problem with this is that: what if I wanted to add a table in the game and the Player tries to walk behind it, but instead it would like the player is just stepping on the table but when it goes behind the walls, it looks just fine. And this is because the Player’s parent is the Wall TIlemap and not the Table TileMap.

I’ve tried making a table scene and adding an Area2D to it and I’ve made a script that makes whatever the body that entered to it be a child of the table. Saved that, converted it to a tilemap but it looks like tilemaps don’t detect Area2D’s so the script wont work.

In my game, I would use a lot of trees and random barrels so setting them up individually would be tiresome and I hope that somebody has a work-around on this problem. Thanks!

:bust_in_silhouette: Reply From: p7f

Hi,
You don’t need to have every node as child as the other one for ysort to work. There is a special node called YSort, and all childs of that will work as you want. Just add an YSort node to your scene, and then add both character and table as child of it. Remember than ysort will work with the center of the objects, so you will have to put the center ob character and table to their foots.

Please tell me if this works!

Just for the record, making a script to the table and then converting it into a tilemap wont work, because tilemaps are just one object with collision in its parts… it won’t handle other kind of stuff besides collisions, lights, etc.

p7f | 2019-01-21 13:02

Hello! Thanks for your answer! Well, if you will read again my question, I did put the tilemap node and the player node under a YSort parent node. like this:

YSort

-Player
-TileMap

And I would think that YSort would automatically sort out the player and the tiles of the tilemap but it doesn’t work.

Putting them individually in the YSort parent as a child works though. Maybe YSort does not sort out tilemaps with other nodes under it.

bodicpen | 2019-01-21 14:45

Hi,
I just tried in my pc and works as i said… can you share me your project to see? I’ll send my modification of isometric tutorial

p7f | 2019-01-21 14:48

Are you on beta or stable release?

p7f | 2019-01-21 14:48

try this: MEGA

It works on my PC

p7f | 2019-01-21 14:54

Well I’ve downloaded the godot engine in Steam and it says there Godot 3.0. Doesn’t mention anything about Beta though.

How can I share to you my project? Can I upload it somewhere?

bodicpen | 2019-01-21 14:55

You can upload to drive or mega or whatever cloud service and paste here the link. I shared you a project… can you see if it works in your pc first?

p7f | 2019-01-21 14:57

I’ve seen the project and unfortunately it’s the same result as mine. The troll looked like he stepped on the wall instead of getting behind it (the walls should load in front of the player but it looks like the player is just going over it.)

Here’s a public picture of what I mean.

123 hosted at ImgBB — ImgBB

Don’t worry about the link. It’s from Imgbb, just a site where you can upload public photos.

bodicpen | 2019-01-21 15:02

So the same project that works in my pc does not in yours? wow, that’s strange… maybe you should install a standalone version from godots web? Share me your project and i see if yours works on my pc.

p7f | 2019-01-21 15:05

This is how it looks in my pc:

isometric hosted at ImgBB — ImgBB

p7f | 2019-01-21 15:09

Okay but I need to arrange the project first because it’s quite a mess right now. But can you try moving the troll to the position where I’ve put it and see if he goes behind the wall because mine didn’t. And show me the picture. I will send a link to my project as soon as I arrange it.

bodicpen | 2019-01-21 15:11

I’m sorry… my bad… i was testing everything in godot 3.1 beta 2… it works fine ther… but not in 3.0.6 stable release

If you are not in a hurry, may be you should change to 3.1.

p7f | 2019-01-21 15:16

Here you have:

isometric hosted at ImgBB — ImgBB

p7f | 2019-01-21 15:19

Great! I’ll try switching. Thank you so much for fast replies! :smiley:

bodicpen | 2019-01-21 16:06

Hi, you are welcome! If it works, you may selec the answer so it doesnt remain unsolved!

p7f | 2019-01-21 16:08

Hello! It does work in 3.1. Looks like just a bug in the earlier versions. All good now. Thanks!

bodicpen | 2019-01-22 12:20

You are welcome!

p7f | 2019-01-22 12:22