I’m making 2.5d game and I want to layering only my player’s part (stickman) and rest of game’s sprites can render with Z axis.
I used sorting layer for the player and order for the player’s parts but result is this
I’m making 2.5d game and I want to layering only my player’s part (stickman) and rest of game’s sprites can render with Z axis.
I used sorting layer for the player and order for the player’s parts but result is this
I wrote my own script
using UnityEngine;
using System.Collections;
public class sorting : MonoBehaviour {
public Transform stickman ;
private Vector3 spritepos ;
private SpriteRenderer sprite ;
public int sortingOrder = 50;
void Start()
{
sprite = GetComponent ();
}
// Update is called once per frame
void Update () {
spritepos = transform.position;
if (spritepos.z < stickman.position.z) {
sprite.sortingOrder = sortingOrder;
}
else {
sprite.sortingOrder = -sortingOrder;
}
}
}
Seen some sorting group example here,
(havent actually tried it so not sure if it does what you need)