Hello!
I’m working on a 2D topdown game that uses bone animations, and I have different Sprite Libraries for the different directions that the character will be facing. Basically I’m trying to figure out how to change the sorting order of the sprites based on the direction the character is facing.
When I press on the left arrow key, the sprite library and bone animation gets changed properly, so that works fine. However, because the sorting orders don’t change, the character looks like a mess!
As an example, the right arm needs the sorting order changed from 17 (in the down-facing direction) to 0 (in the left-facing direction).
I am aware of this method:
mySpriteRenderer.sortingOrder = /*[Sorting Order Number]*/;
However, I believe I would have to use that for every single sprite Category, so I’m trying to avoid that.
As an alternative, I’m trying to create a script that I can assign to the Player prefab that can change the sorting order of multiple sprites based on the direction the character is facing.
I was trying to accomplish this by listing out the names of the Categories in the Sprite Library using enums, but I’m new to Unity and to coding in general, so I’m having trouble figuring this out.
Any help would be appreciated! Thanks so much!