How do I make a loop to only continue after my function is finished?

Hi, right now I am saving the the vector (x,y,z) inside a array with enhance_click function,
I want my character to move to the location with the move_to function step by step, so this is my first idea to do this


But seems like using for each loop is not a good idea, my character only move to the location of the last element in the array , I check that it does loop through the array, but seems like it is too quick that all of the previous move_to function got cancelled and only the last one success.

I think I should make a manually loop, but don’t know how to do it, can anyone give me some idea?

The Loop function is set to execute as quickly as possible. So it will not wait for the character to move to a location before it moves on to the next value.

You could use the vector points to setup a spline. With the spline you can now move between the points quite easily. Alternatively you can run a function that moves the character to the first index, and have a check that verifies the character position before it should move on to the next location.

1 Like