private void LateUpdate()
    {
        //if (start)
        //{
        //    snakeTail.UpdatPos(this.transform.position);
        //}

        if (changeDir)
        {
            if (snakeTail != null)
            {
                snakeTail.addPath(new pointDirection()
                {
                    point = this.transform.position, direction = direction
                });
            }
            changeDir = false;
        }
    }
Beispiel #2
0
    private void Update()
    {
        if (!Manager.isGameOver)
        {
            if (path != null && path.Count > 0)
            {
                pointDir = path[0];

                if (ReachedCheckPoint(pointDir))
                {
                    Debug.Log("Point is " + pointDir.point);
                    direction = pointDir.direction;

                    if (snakeFollow != null)
                    {
                        snakeFollow.addPath(path[0]);
                    }

                    path.RemoveAt(0);
                }
            }

            CheckDistance();
        }


        //if (path.Count > 0 && CheckDistance())
        //{
        //    if(Math.Round(path[0].z,2) == Math.Round(this.transform.position.z,2) && Math.Round(path[0].x,2) == Math.Round(this.transform.position.x,2))
        //    {
        //        path.RemoveAt(0);
        //        iTween.MoveUpdate(gameObject, path[0], 1f);

        //    }
        //    else
        //    {
        //        iTween.MoveUpdate(gameObject, path[0], 1);
        //    }
        //}
    }