Y-sort background sprite problem

Hey Guys im working on a top down action rpg and i use the y-sort extension it works great on all of my small sprites i also use a sprite as a background and that sprite is bigger then my camera size so the camera just follows my character but when i reach the top of my starting screen camera border my character goes behind the background sprite now I tryd giving my background sprite also a z order with his point and that worked but im using 2 backgrounds on 2 different layers and now it doesnt work but i dont understand why i cant just use 2 sprites as background and layers beneath my character with my character going beneath my backgrounds

Ysort is based on the Y position of the Origin Point, not the boundaries of the sprite.

If the background OP is on the bottom border, while the OP for the character is in its middle, the character will register as having a lower Y position than the background, and therefore a lower Z-depth.

i understand but is it not possible to make background sprites that act like the default gdevelop background without OP?

Why can’t you just set the Origin Point correctly?

Hold on, why do you even use YSort on the background?

Shouldn’t the background always be in the background?

No that is what i am saying maybe im a total noob but i just want to use is as background but i can only use sprites

Just set the background to a lower Z-order than the character. No YSort required.

that doesnt work thats what im saying i dont want Ysort on the background but its like the Characters y-sort is forcing it i just but the background sprite on lower z-order without y-sort on it and the character still goes behind the background sprite

Yes, as said, it happens because the background Z-order is higher than that of the character… Simply set the background to a lower value. Try negative 10000.

No thats not the problem my background z-order i put it way lower then my characters z order and in beginning the charater is infront but as soon as i reach the original top camera border the charcter goes behind the background

1: Which value exactly do you set the background to?
2: Which value exactly do you set the character to?
2: Are you using YSort still? For which Objects?

1: Background Z-order -80 Base Layer
2: Character Z-order 60 Base Layer
3: Character Change the z-order of Player_sprite:set to Player_sprite.Y()

So only Ysort on character not background

What is the Y position of the character when you run into the issue with the player being hidden behind the background sprite?

0 i have a resolution of 320 by 240 so its the very top of my screen

YSort does not use the screen position, but the world position.

You should do as I suggested originally and set the background Z-order to -10000.

It works thanks man sorry for being so stubbern and stupid haha how can i see the world position?

1 Like

An easier solution here would to be to make a separate layer called background, put the bg object on it, then move that layer under the base layer.

You’ll need additional events to keep the camera synced, but the background will always stay in the back, unaffected by Y sort.

(The events to keep them synced is likely what is being missed, going off the opening post)

Object.X() and Object.Y()

Just ignore screen position entirely. It is only relevant for placing static elements like GUI buttons, bars and sliders.

Game objects use world position. Otherwise they would be unable to position beyond the confines of the screen. World position is relative to the camera position.

How do you feel that all that extra work and the performance overhead can justifiably be called “easier” than simply setting a low z-order value?