// Set real coordinate position private void SetRealPos() { float[] coords = ChessGrid.GetRealPos(Position); Vector3 pos = new Vector3(coords[0], coords[1]); transform.localPosition = pos; }
private void Update() { // Always interpolate position over time back to where it is set at float speed = 10 * Time.deltaTime; float[] coords = ChessGrid.GetRealPos(Position); Vector3 pos = new Vector3(coords[0], coords[1], 0); if (!dragging) { transform.localPosition = Vector3.Lerp(transform.localPosition, pos, speed); if (Vector3.Distance(transform.localPosition, pos) < 0.01f) { SpriteRenderer.sortingOrder = 0; } } }