2D Sprite Renderer Order in layer Issue

Hello everyone!

I have some problem with platforms in 2D project. The thing is, that platform I’m using for my character to stand on has the protruding rim, which overlaps my character like on picture. Platform has Box Collider, Platform Effector, so the knight can jump through it. An issue appears, when character is jumping below the box collider, it’s still overlapping character, like on the second picture. How should I fix this? Change the Order in layer by script, or use some sort of animation to make the barrier transparent and visible when character is higher than certain point? And what functions and commands in C# can change the Order in layer?

I would be very grateful if someone help with this issue. Thanks for the attention!

5847508--621013--Снимок экрана 2020-05-14 в 15.51.49.png
5847508--621016--Снимок экрана 2020-05-14 в 15.52.10.png

You could try: rim.GetComponent<SpriteRenderer>().sortingOrder = someNumber; Then flip it to the original number when the jump is over.

Alternatively, when jumping, you could from your knight knight.GetComponentsInChildren<SpriteRenderer>().ForEach(sr => sr.sortingOrder = someNumber)

So instead of moving the rim around in response to what the knight does, the rim doesn’t do anything and instead you move the knight’s order around, which seems less coupled to me because it’s the knight doing the jumping.

Thanks a lot for the answer, I’ll try do it!