Move object through vector list

Hi everyone!

I created an pathfinding algorithm that returns a list of vectors. This list is updated through the Update() method.

Basically I need to move an object though all the vectors of that list one at a time, but I can’t figure out how.

The maximum I managed to do is to “teleport” the object straight away to the ending vector. How could I do this? Any idea is appreciated!

To move your object to a position you can use somethink like this:

transform.position += (nextPoint - transform.position).normalized * Time.deltaTime * speed;

You would have to check wether your object as reached the next point or not. If the point has been reached, you need to get the next point out of your list.

if(Vector3.Distance(transform.position,nextPoint) < someTreshold){  //Next point in list has been reached
   currentIdx += 1;  //Count the index one up
   nextPoint = yourList[currentIdx];  //Get the next Vector of the list and store it