Hi, I have script where my object move in isometric view, but something work bad because on axis Y my sprites have bad position and I must manual add + 0.3f (screen 1).
I want my sprites to have the correct positions like in screen 2.
Addition question, how durring move object set my mouse position in place “X” on screen 1 ? (I think its correct mouse position to move objects in isometric view)
Code:
public class MoveObject: MonoBehaviour
{
public float tileWidth;
public float tileHeigh;
public float x;
public float y;
public Vector3 position;
public Vector2 buildingPosition;
void Start()
{
// Get sprite size
tileWidth = (float)gameObject.GetComponent<Renderer>().bounds.size.x;
tileHeigh = (float)gameObject.GetComponent<Renderer>().bounds.size.y;
}
void Update()
{
x = (position.y * tileWidth / 2) + (position.x * tileWidth / 2);
y = (position.x * tileHeigh / 2) - (position.y * tileHeigh / 2);
buildingPosition.x = x;
buildingPosition.y = y;
transform.position = buildingPosition;
}
}
“position” I set manual, but if I set [1,0, 0] code calculate to correct isometric position but not for axis Y .