Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (timeSinceLastNode >= timeBetweenNodes)
        {
            ++i;
            timeSinceLastNode = 0f;
            if (i == rP.NodeCount())
            {
                Destroy(this.gameObject);
            }
            else
            {
                nextNode = rP.GetNode();
            }

            moveRate = CalculateMoveRate();
        }

        Vector3 dir = nextNode - this.transform.position;

        this.transform.Translate(dir.normalized * moveRate);
        timeSinceLastNode += Time.deltaTime;
    }