I agree with that setting the Direction on Tick by a delay is a bad idea and should be done with a Timer.
A normalized direction where x and z is zero will always result in 1y (Right) or -1y (Left) so that is why it doesn’t matter what number you set y to it only matters if it is positive or negative.
There is 3 ways I can think of on the spot that would have you know when you moved a certain distance that doesn’t involve physics.
- You do like your book suggests and use time and speed to determine distance. If the speed is constant this is an easy and efficient way of measuring distance traveled.
- You add the relative distance you move every frame and check that distance traveled every frame and change direction if you have reached the desired distance.
- You measure the distance from your start location every frame. If you only move on one axis this is a simple subtraction but if you move on two or more axis this is a square root operation and becomes the least efficient of these 3.