I can't get YSort to work...

thatsweeneyguythatsweeneyguy Posts: 13Member

So, I have my player scene and "tree" scene as children of the same YSort node.

When I run the game though, the layering still isn't working, and my player just walks on top of the trees...

I have no idea what I'm doing wrong, as I thought all I needed to do was make sure everything was a child of the same YSort node and they'd be sorted.

Comments

  • MegalomaniakMegalomaniak Posts: 2,028Admin
    edited March 21

    Y-sort works by the object pivot(origin) point.

    remember that in the case of an instanced scene the scenes 0, 0 is the origin.

  • thatsweeneyguythatsweeneyguy Posts: 13Member

    so would I just need to set the scene's origin at the same time I set its position when the scene is instanced?

    The way my game is built, each tree is generated as a scene at runtime, and in order to get them into the right place, I had to manually position it when it's created. Is there a built-in variable for the pivot?

  • thatsweeneyguythatsweeneyguy Posts: 13Member

    So, the pivot is where the tree is positioned on its scene yeah? My player and Tree are both placed so the 0,0 point is at the base:

    This doesn't seem to make any difference though. I'm so lost.

  • MegalomaniakMegalomaniak Posts: 2,028Admin

    Well, it's working here... are you sure the YSort node is turned on? It's got a property for controlling it's effective state, maybe you have it set to off?

  • Stefan_GameDevStefan_GameDev Posts: 44Member

    Also, make sure you haven't got any z-index interfering with the ysort.

    For another tutorial on ysort

  • thatsweeneyguythatsweeneyguy Posts: 13Member

    @Stefan_GameDev said:
    Also, make sure you haven't got any z-index interfering with the ysort.

    OH MY GOD! Even without the video, that single sentence solved my problem. I had the Z-index set to 1 on both the player and the tree because I was layering them differently before. I figured that if they were on the same index, the YSort should keep them in line. I never thought to just reset them to zero...

    I'm still really new with godot, and just as I thought it would be, this was something super silly that I should have recognized lol

    Thank you so much. This has been killing me for the last few days

  • Stefan_GameDevStefan_GameDev Posts: 44Member

    YSort should work with 2 nodes being on the same z-index, but maybe they were set to relative and one got more z-index from its parents than the other.

    Anyway, glad you got it working :)

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file