Example #1
0
        public void findNextPoint()
        {
            float miniStep = intervalLenght / 10; //used to segment the interval (could be calculated differently based on the T vector to optimaze the code)
            float i        = step / (numberOfPoints - 1);

            //Check if this is the last step (the next point will be the end point)

            //TODO finish this
            if (step == numberOfPoints - 2)
            {
                nextPoint = curve.endPoint.transform.position;
                calculateAcc();
            }
            else
            {
                Vector3 position = coordinate;
                float   length   = 0;

                this.nextPoint = this.coordinate;

                //calculate points untill finding the next one with lenght equal or greater than the interval defined
                while (length < intervalLenght && position != this.curve.endPoint.transform.position) //TODO: maybe there should be a condition checking if the curve has ended
                {
                    i        = i + miniStep;                                                          //step forward on the curve interval
                    position = curve.generatePoints(i);                                               //generate the point for the mini step
                    length   = Vector3.Magnitude(position - coordinate);                              //calculate the length to the point generated
                }
                this.nextPoint = position;

                //TODO Treat case when the next point wasn't found
            }
        }