Hi,
The attached image shows a problem I’ve got for ages and I don’t know to solve atm. If you by any chance know of a way how to make this work, please tell me.
The game in the making is a 2D top-down game.
What I want to achieve:
I want a correct rendering order for all the elements shown. The player character is onboard the coach, so he is behind the coach’s curtain and in front of (on top of) the chassis.
The issues
If I use a pivot-based sorting order sorting system (meaning the sprites are rendered on the same sorting layer according to a changing sorting order that depends on the y-value of its pivot point), the result is that the player is sometimes in front of the chassis when the player’s pivot point is below the chassis’ pivot point, and sometimes behind it (when moving upwards). The same happens with the curtain.
If I resort to different sorting layers, I have huge problems to maintain compatibility between the different game objects. For instance, if I let the curtain render on a sorting layer that is in front of the player and the chassis, it’s also in front of the wheels like shown in the picture. I simply can’t put the wheels on the same sorting layer as the curtain because it wouldn’t make sense. Ground objects like stones would never be able to get behind the wheels, because they are ground objects and located on a lower sorting layer.
Another case:
When the player exits the vehicle for instance, he’s not on top of the coach’s chassis anymore, so he can walk behind it. But he needs to be displayed in front of it when he’s climbed on the chassis. Same goes for the curtain. When he’s on top, he’s always behind the curtain, but when he’s standing in front of the coach, his head is supposed to be rendered on top of the curtain.
The big question
How can I put a system in place that allows correct and dynamic rendering of all sprites?
Any clue helps. Thank you very much.