Example #1
0
    IEnumerator MoveAlongPath()
    {
        float elapsedTime;

        while (indexAlongRoute < route.Count)
        {
            Vector3 currentPosition = this.transform.position;
            Vector3 targetPosition  = route[indexAlongRoute].transform.position;
            elapsedTime = 0f;
            while (elapsedTime < timeToMoveBetweenTiles)
            {
                yield return(new WaitForFixedUpdate());

                elapsedTime            += Time.fixedDeltaTime;
                this.transform.position = Vector3.Lerp(currentPosition, targetPosition, elapsedTime / timeToMoveBetweenTiles);
            }
            this.transform.position = targetPosition;
            indexAlongRoute++;
        }
        LivesController.DecrementLives();
        spawner.IncrementEnemiesDestroyed();
        Destroy(this.gameObject);
    }