Esempio n. 1
0
        // Set real coordinate position
        private void SetRealPos()
        {
            float[] coords = ChessGrid.GetRealPos(Position);
            Vector3 pos    = new Vector3(coords[0], coords[1]);

            transform.localPosition = pos;
        }
Esempio n. 2
0
        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;
                }
            }
        }
Esempio n. 3
0
 private void Awake()
 {
     Instance = this;
 }