// Update is called once per frame
    void Update()
    {
        if (!_tileMovement.moving && sliding && Vector2.Distance(targetPos, transform.position) > 0.01f)
        {
            sliding = _tileMovement.MoveDirection(slideVector);
        }

        if (Vector2.Distance(targetPos, transform.position) < 0.01f)
        {
            sliding = false;
        }
    }
Exemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        if (!stopped && moving)
        {
            if (!_tileMovement.moving)
            {
                if (Vector2.Distance(transform.position, currentTargetPosition) < .001f)
                {
                    SwapTargetPosition();
                }
                else if (!_tileMovement.MoveDirection(VectorTowardsTarget()))
                {
                    SwapTargetPosition();
                }
            }
        }
        //transform.position = Vector2.MoveTowards(transform.position, currentTargetPosition, moveSpeed * Time.deltaTime);

        // _rigidBody.MovePosition(Vector2.MoveTowards(transform.position, currentTargetPosition, moveSpeed * Time.deltaTime));
    }