Updating the position of an object step-by-step

Hello! I am trying to take json data for height and a known delay to move an object vertically. However, the function that I am using does not work. It jumps to the end instead of going step by step and delaying by the time I have dictated. I have provided a playground showing my exact issue. Thanks for any help you may be able to provide!

The setTimeout function callback isn’t triggered until the for loop execution has completed. So you will always get the last value (40 in your case).
I would recommend to use CreateAndStartAnimation functions here - Advanced Animation Methods | Babylon.js Documentation


You do always use 500 ms of delay for all, it should rather be (i+1)*500.
Your move-Vector3 is immediately changed in your loop, while setTimeout uses the value of move-Vector3 after delay, which will always be y=40. To solve this, I would use moves-array.

Playground Example: