Ejemplo n.º 1
0
    private void Update()
    {
        startPos   = path.GetStartPosition();
        startPos.y = transform.position.y;

        endPos   = path.GetEndPosition();
        endPos.y = transform.position.y;

        if (transform.position.x == startPos.x)
        {
            newPos = endPos;
        }
        else if (transform.position.x == endPos.x)
        {
            newPos = startPos;
        }

        transform.position = Vector2.MoveTowards(transform.position, newPos, speed * Time.deltaTime);
    }