Forum rules - please read before posting.

Sorting Layer & NavMesh Hole

Good morning Community,

I have an issue with the sorting layer and the NavMesh Hole. Let me explain better: I followed the tutorial step by step, and since I'm using URP, I also added the script SetTransparencySortAxis.cs to the Camera. However, I’m experiencing the following problem:

The player (I'm using the tutorial's prefab without any modifications) correctly recognizes the NavMesh Hole and moves around it, but it does not follow the sorting layer parameters. As a result, it always maintains the player’s order layer priority.

Specifically, my setup is as follows:

The player is on sorting order 0.
The object around which the player moves is on sorting order -1.
I created a sorting layer at 1 for when the player is behind the object.
From my understanding, the player should appear behind the object when the sorting priority changes, but I can’t seem to get it to work correctly.

Any help would be greatly appreciated!

Comments

  • The use of transparency sort axis, and the Sorting Map, are two methods of achieving the same result. If you're using both, it may be that they're conflicting with one another.

    When using the Sorting Map, the sorting layer above the object will need to be less than -1.

    However, you can ignore sorting values completely by unchecking Affect character sorting? (or removing the Sorting Map if it doesn't affect scale either), and just rely on the sort axis.

    For this, set the sort axis to Custom, (0,1,0), and then place the character and the object on the same order (0). Set the object SpriteRenderer's Sprite Sort Point to Pivot, and adjust the sprite such that it's pivot point is at its base. When the Player move above this point, they should then appear behind the object.

  • I'm still a bit confused. I don't quite understand how to use Sorting Maps and Follow Sorting Map. Let's start from scratch: I have an object in the scene with layer 0, just like the player (0). In the Hierarchy, I created a Sorting Map, to which I should add areas. Both the player and the object have their sprite sort point set to Pivot. What should I do? What script should I add, and how should I manage the areas of the Sorting Map?

  • The Sorting Map deals with multiple aspects, but just on the topic of sorting: technically you don't need one with more recent versions of Unity. So long as your transparency sort axis is set to the above, then sprites in the scene with the same "Order in layer" will sort correctly based on their vertical position.

    A tutorial can be found here.

  • Hi Chris, first of all, a thousand thanks for your patience and for the always quick responses, but nothing, I’ve tried everything. I’ve added your Set Transparency script. I’ve configured the 2D Renderer by setting the Transparency Sort Axis to Y1. I’ve left both the player prefab and the object on the same order in layer. I’ve assigned the Follow Sorting Map script to the player and in the ‘sorting map to follow’ field, I’ve selected the correct sorting map (left it as default). But still, it’s not working, and I don’t understand why.

  • If all is set up correctly, you shouldn't need to involve a Sorting Map, nor enter Play Mode, to see the effects of it.

    What is the exact behaviour you're now getting? Share screenshots of the issue - including the scene, the full Inspectors of the objects involved, your URP settings, and the object's sprite.

  • Hi Chris, maybe i resolve. I think was a problem about my confinguration of sorting area. Also in project files I changed the sprite pivot directly from there and now it work. I have just little problem with the Navmesh Hole but I think I can fixed without problem. One more time, many thanks !

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.