I’m trying to get Ysort working for each obgect. It does work between the character and the door, but it doesn’t properly with the tree.
Even if the edited point is at base for each obgect, when I’m behind the tree leaves, it seems it doesn’t work unless I’m at the the really top of the sprite.
I can’t add more screenshots since I’m a new user , but if i go one step down the character goes on top of the tree sprite.
If the origin points are central then you need to set z order to the object y plus half the object height in order for it to work. Have you used the z behaviour or a line of code?
I’m using the Ysort behaviour without code. I just noticed that if I put the origin point on the center edited point it works fine. But I don’t know if it is the right way or if this gonna mess something in the future.
Great! if it’s working then it’s taking the height of the object into account. I don’t use the behaviour myself as its really just one line and sometimes you need to tweak it. If you havent done so already you can do things like set the collission mask to just the base of the tree or object so that it’s an obstacle but you can go behind it.
On points … generally put the origin in the centre if it’s interacting with things.with tiled objects the origin is top left and so refer to the centre as X plus half object width, y plus half object height, if the angle of it is zero.
You can also do things like put the origin far left if you want to extend it or put the center point far left if wanted to rotate it around that point.
hi mrmen - he’s using the z sort behaviour which must add half the height to the y as he’s said it’s working now, but yes it could be useful to work with the origin at the bottom on a game like this one.
It’s Y sort, not Z sort. It sets the z value base on the object’s y position. And it shouldn’t need to use any extra events to reposition objects.
Putting it at the bottom is where it should ideally go. Then anything further down the screen (appearing to be closer to the viewer) will be placed in front of objects hight up the screen (or further back). Placing it in the middle of the object can cause visual issues when the objects are of different heights.
And using the bottom middle means there is no need to make any calculations. Here’s an example of that in effect in my recent game with the origin at, or very near, the bottom middle of the object (ironically using the same sprite package as @Roger9). It uses the Y-sort behaviour without any positioning extra events: