Exemplo n.º 1
0
    void StartMover()
    {
        if (moving)
        {
            return;
        }
        moving = true;

        Vector3 f = GetPointAtPosition(path[pathPosition]);
        Vector3 t = GetPointAtPosition(path[pathPosition + 1]);

        pointPosition = path[pathPosition + 1];
        Vector3 next = pathPosition + 2 < path.Count - 1 ? GetPointAtPosition(path[pathPosition + 2]) : new Vector3(-1, -1, -1);

        rotator.InitMovement(f, t, next);

        pathPosition++;

        float speed    = 2f;
        float distance = Vector3.Distance(f, t);
        float time     = distance / speed;

        Co2.StartCoroutine(
            time,
            (float p) => { Move(p, f, t); },
            OnArriveAtPoint
            );
    }