Hello! I have done some animations with inventory objects and the problem is that in the beginning they are in the **Back **Sorting layer because they start hidden.
But when I do the animation for them I can't change the** Sorting layer,** so objects are hidden by other objects. I need that the turtles will be in front of the chair. I have tried at the timeline and animation window and don't allow me to change sorting layer there. I also try to do with action lists but there is no option to change sorting layer in objects. Also I try to use "Follow sorting map" in the turtles but if I do that turtles don't teleport to their new location.
Help?
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
Unity doesn't allow for a Sprite Renderer's Sorting Layer to be animated, but you can do it with the help of a custom Action:
Install that as in an Action script named ActionSpriteLayer.cs using the instructions in the Manual's "Custom Actions" chapter, and it should then be available in ActionLists as a new "Object: Set sprite layer" Action.
It worked . Thanks a lot for the code.
Hi there. I followed these instructions and I have the Object : Set Sprite Layer action availabe in my ActionLists but nothing happens when I use it.
There is no error message, the object simply does not change layer. I have tried it on a few different objects and get the same result.
Any advice? Thank you.
If the Action runs without any error, the spriteRenderer variable is being properly assigned - try placing this at the top of the Run function to check:
What object have you assigned in the Action, and what else is attached to it? Any relevant screenshots of the Action and object will help pin the cause down.