I am trying to make a 2D Isometric game with the Orthello 2D extension, but I’m struggling with the rendering order a bit.
So, first of all I’ve set the World in the OT object to WorldTopDown2D. That means that the X and Z values of objects only matter for their position, the Y value is just for the rendering order. The problem comes when I try to build a tile-based terrain (using a Sprite object with a single tile, because I’m using the free version of Orthello.) As far as I understand the logic of Orthello is: objects with higher Z value should be rendered on top on objects with lower Z value and objects with lower X value should be rendered on top of objects with higher X value. And you can clearly see that when you begin moving your objects around in the editor(the Y value changes ever so slightly.) Unfortunately I need to have the exact opposite behavior for my Tiles, because they are in an Isometric view(the angle in which Bastion is made.) Obviously for other objects(like the main character) I can use the Depth value of the Sprite object, but that will be super annoying to do for each Tile.
Could you maybe just whip up a little script that sets the depth of each tile based on it’s X and Z value and attach it to your sprite prototype? Something like
using UnityEngine;
using System.Collections;
public class SetDepth : MonoBehaviour {
OTSprite mySprite;
// Use this for initialization
void Start () {
mySprite = gameObject.GetComponent<OTSprite>();
//You might need to flip the sign (not sure which way is closer
//to the camera) and scale it
mySprite.depth = transform.position.x - transform.position.z;
}
}
Thanks for the answer, that’s a quick and effective solution. The only problem is that when you are in the editor everything seems to overlap incorrectly and it’s hard to align tiles together, if you understand what I mean.
I can’t really picture the geometry in my head, but have you tried using “WorldSide2D” instead of “WorldTopDown2D,” or is there a particular reason why you wouldn’t want to use it? It might give you the behavior you are after.
Otherwise you could extend the editor and make a button to set the depth of all the sprites, that should work I think.
I use TopDown because it makes most sense. I’ve tried Side2D, but the result was the same. That aside, I think I’ve solved my problem. I found the function where that Y calculation was happening and modified it so that it works for my scenario. I only hope that I’m not breaking any licence agreements with that.