#Trying to add Ysort to 2D project in Godot 4.2.1

118 messages · Page 1 of 1 (latest)

static nacelle
#

I want to learn godot to work a game for fun and learning experience and if been following a tutorial and reached the point of adding Ysorting. Right now the Ysorting is not working while I followed the steps (I think).

Right now the things if setup for Ysorting is as follows:
I have a MainLevel with a childnode TileMap and inside the TileMap a childnode to Player.

MainLevel has:
Z index = 0
Y Sort Enabled = ON

TileMap has:
A layer called Ysort which includes the tree I want to walk around:
This layer also has:
Z index = 1
Y sort Enabled = ON

and

The main TileMap has:
Z Index = 0
Y Sort Enabled = ON

as Last, The Player has:
Z Index = 1
Y Sort Enabled = ON
( I would like to add the point that when I click on the player below TileMap, I get some settings for YSort and also when I go to the Node itself, there is different Settings. I tried playing around with both but still it isnt working..)

I added to the tree sprite at the tap Rendering the Z index to 1, Y Sort origin to a lower point at the trunk

With these settings the player is always behind the tree sprite, I need to get the sprite infront of the tree the moment it walks lower then the Y coords of the tree.

What am I missing or is there a setting that could conflict when its turned on that I maybe set on while playing around? If needed, I can go call and show everything

#

Feel free to ask for more information or clear-ups if needed!

rough venture
#

your player does not have to be a child of the TileMap for this to work

#

how is your player scene setup?

#

is the content aligned to the bottom?

static nacelle
#

You mean this setup?

rough venture
#

is the player feet at 0, 0

static nacelle
rough venture
#

ok

static nacelle
#

Yes

rough venture
#

ok, I read carefully your text now. I believe the problem is the different Z levels

static nacelle
#

Should I set all the Z levels to 0?

rough venture
#

to Y Sort to work things must be at same Z level

#

yes

static nacelle
#

Alright Ill change that

#

A question in between while I change this, I got to places to click to go to my player and both feel like different settings:

#

When a click on Player (below TileMap) I see Ysorting is on, when I go next to world, I see Ysorting Off

rough venture
#

the one on the tree is the one instantiate on the scene. So the changes in you do to it will override the original scene

static nacelle
#

Ahh okay very good to know

#

When I change the Z to 0 I get :

rough venture
#

the settings in the original scene will be used if you create a new instance

#

if you don't want to use Y sort for a layer you can change the Z index

#

like this example

#

I want the floor to always be on the background

#

So I changed the Z Indez to -1

#

and disabled Y Sort

static nacelle
#

Ahh okay let me try

#

I added the changes, Everything is 0 Z expect the background and some flowers I have. Still the charater is not getting infront of the tree

#

Do you have time today for a discord call? You dont have to speak, but I can show you all the things with screensharing?

rough venture
#

did you change anything on the character sprite Z index?

static nacelle
#

You mean the Sprite2D?

rough venture
#

yes

static nacelle
#

Uh no, Y sort is not enbaled on this I see

rough venture
#

I think is easier if you zip the project and send for me to take a look

static nacelle
#

Alright! How can I zip the project?

rough venture
#

it depends on which OS you are. Windows 11 you can just right-click the folder and compress to zip

#

otherwise you might need a third party program

#

to create a .zip or .rar

static nacelle
#

Windows 10

#

I got WinRar

rough venture
#

it will probably show in the right-click options

static nacelle
#

I hope this helps!

rough venture
#

gimme a sec

static nacelle
#

If you manage to open it and find the solution, Please tell me, would love to know which mistake I am making

rough venture
#

your game is cursed gddeadinside

static nacelle
#

Oh no..

#

The settings are good but just not working cursed? or files corruped curse?

#

Should I start over again?

rough venture
#

I think I found

#

just a sec

static nacelle
#

Oh

rough venture
#

you need to adjust the Y Sort origin value

#

16 still behaves weird

#

but you can tweak to find the best point

static nacelle
#

Wait does this point mean like 16 layers deep>

#

So I need to set this back to 0?

rough venture
#

or use 16 and push the collider a bit down

#

that is where the Y Sort will take the origin point of the cell

#

by default is 0

static nacelle
#

Ahh

#

Ill play aroudn with this one, Thank you! Ill let you know if its fixed

#

If you by any change found a nice value, let me know!

rough venture
static nacelle
#

And the dog will be in the front, when below the tree?

#

Because I had it always in the back sadly

rough venture
#

for that collision setup 12 works

static nacelle
#

Alright! Ill try that soon, have a meeting now. Then ill let you know if it worked!

#

Oh looks good!

static nacelle
#

Okay, I am trying to implement the changes you found. But it is not working yetsadly

#

I put the point where It should swap in like the trunk era, and changed y Sort to 12

rough venture
#

ah

#

I have found something else you have changed

#

let me remember what it was

#

the z index

#

is 1

#

should be 0

#

in the tile

static nacelle
#

Ohh yeahh

#

So basicly, Instead of making all the Z = 1, we keep it 0 but change the others Z to -1?

#

Oh, now I am always above the tree, hmm

#

Wait could you send the project back with the changes, then I go over 1 by 1 and see whats going on haha

rough venture
#

you only change the Z index of the Layer you want to be always behind or in front. Those that should not be affected by Y Sort

#

the rest you leave at 0

static nacelle
#

Yes If changed those

#

everything is 0 accept my background (and some flowers which are basically the background)

#

When I place a new tree, this happends.. There must be something im doing wrong at the tile

rough venture
#

wait, I have deleted the project

#

I need to try again

static nacelle
#

Alright, take your time. Thanks for helping me out!

rough venture
#

aaargh

#

I don't remember what I else I could have changed

static nacelle
#

Oh those steps are not working on your side? Thats kind of good so I know my system isnt broken

#

I hope you can find the last change

#

I am also in the meantime trying things

rough venture
#

is your player set to Top Level?

static nacelle
#

I never touched this setting before haha, let me check

rough venture
#

check the on instantiate to be sure

static nacelle
#

It is yes

rough venture
#

I think mine was before because a deleted the player and add a new instance

#

to be sure it was like the original

static nacelle
#

So it should be on?

rough venture
#

just disable that

#

no

static nacelle
#

Alright

#

Oh it works now!

#

Found a wierd spot, but thats just tweaking things around

#

Atleast the whole Ysort works now!

#

Thank you so much for helping me out and putting the time into this