I’m making a 2d rts, and i’m trying to make it so that it appears that units can go in-front of and behind objects
like this
l

I’m making a 2d rts, and i’m trying to make it so that it appears that units can go in-front of and behind objects
like this
l

You have to use the shorting layer at the inspector at the SpriteRenderer side
I know,i want it appear that it is behind the tower when, when from the player’s prospective it would be and be infront of it when from the player’s prospective it would be.
if (player.transform.position.y < transform.position.y)
{
sprite.sortingOrder = player.GetComponent<SpriteRenderer>().sortingOrder - 1;
}
else
{
sprite.sortingOrder = player.GetComponent<SpriteRenderer>().sortingOrder + 1;
}
sprite is the sprite render and player the player gameObject
Put this in the update funktion it will work for objects that are not part of the tilemap.
If someone find a way how to do this with tiles please leave a replay at my thread.
you have some video of your game?
thx m8
Well if your castle is static, it’s better to update the sorting order of your player and assign the castle sorting order at start depending of its Y position