# Layering with slopes in Unity 2D isometric scene

I'm newer to Unity so bear with me. I'm using Unity2D and so far I have my character up and walking around, colliding properly with his surroundings, and I've implemented an effective "isometric sorting" script which swaps the order of sprites based on their y coordinate. What I'm trying to do now is create a slope that exists in the middle of the stage or front (bottom of screen). I'll illustrate what I'm trying to do as explaining it is bound to be confusing.

Right now, I have the ability to move the player up the slope, and in front of the slope (using the isometric sorting script), but it seems maybe impossible to also be able to have the player walk behind the slope.

Here's my idea for how this could be accomplished, but I certainly would need some direction.

Basically, I'm thinking if I can detect that the player has crossed the green line in the image, I could use that information to flip a switch ON which would lower the slopes sorting priority (thus lowering it beneath the players feet), then I would need it to deactivate when the Player exits the slope.

Here is the Isometric Rendering script:

    using UnityEngine;

[ExecuteInEditMode]
public class IsometricSpriteRenderer : MonoBehaviour {

void Update ()
{
GetComponent<Renderer>().sortingOrder = (int)(transform.position.y *       -1000);
}
}


Thank you to anyone who bothers to take the time to help me! I really appreciate it!

• Why not just add a "z" value to each item in your isometric game? Higher y gets priority in sorting. The same y yields sorting based on the highest z. – Coburn Jan 14 '16 at 2:33
• Thanks for the response, DMGregory. I'm going to see if I can come up with a way to make that work. – Matthew Jan 14 '16 at 3:47