Hi all,
I am making a 2d game where I want dynamic sorting orders. Just as an example, when I have the player stand in front of a tree, I want the player rendered on top, but when the player moves behind a tree, I want the tree to render on top. Now if I were simply working with regular sprites, this would be easy. I could just tweak the Z values, based on the Y values. But the problem is that I am using rigged characters with each sprite, on a different sorting order. This means all the limbs have a different sorting order. So if I start tweaking Z values now, the only limb that gets affected, is the one that has the same sorting order as my tilemap. Is it possible to achieve what I want with skinned characters? If the “order in layer” parameter was a float, I could actually make it work because then I would be able to set the sorting value of the left arm to a value of “Y pos + 0.001” and the value of the right arm “Y pos + 0.002” and so on. But alas, this isn’t an option.
The only viable method I’ve thought of so far is to create a “collision box” of sorts behind all the houses/trees/rocks etc that detect when a player steps into that zone, and then changes their sorting order respectively. But this seems rather resource intensive. This way I have regular collision boxes and additional triggers zones. I can imagine that with a lot of objects and characters in the scene, it’s going to be insanely resource intensive, iterating through 2 sets of collision boxes.
Edit: How resource intensive is collision detection if you’re primarily using box colliders? Is it reasonable to have thousands? If thousands of colliders is fine, I suppose my proposed method isn’t too unreasonable.