Your program was working - it was just moving too fast to see.
I've modified your code to do it a slightly different way because there's no way using the move command to guarantee that the 'cow' would ever be in
precisely the same position as the waypoint. (You would have to alter your code to check if it was
near to the waypoint).
Randomize Timer()
Sync ON : Sync rate 60
AutoCam Off
DIM CowWander(4,2)
CowWander(1,1)=Rnd(500):CowWander(1,2)=Rnd(500)
CowWander(2,1)=Rnd(500):CowWander(2,2)=Rnd(500)
CowWander(3,1)=Rnd(500):CowWander(3,2)=Rnd(500)
CowWander(4,1)=Rnd(500):CowWander(4,2)=Rnd(500)
Rem 4 Flags Placed At Waypoints Using Objects 2 to 5
For N=1 To 4
Make Object Cube N+1,1
Scale Object N+1,100,400,100
Color Object N+1,RGB(255,0,0)
Position Object N+1,CowWander(N,1),1,CowWander(N,2)
rem Hide Object N+1
Next N
Make Matrix 1,500,500,50,50
Make Object Cube 1,3
position object 1,CowWander(1,1),1.5,CowWander(1,2)
NextFlag = 2
point object 1,CowWander(NextFlag,1),1.5,CowWander(NextFlag,2)
Do
CurrentFlag = Object Hit(1,0)
If CurrentFlag > 1
NextFlag = CurrentFlag+1: If NextFlag=6 Then NextFlag=2
point object 1,CowWander(NextFlag-1,1),1.5,CowWander(NextFlag-1,2)
Endif
move object 1,1
Set Camera To Follow object position x(1),1.5,object position z(1),Object Angle Y(1),10,5,50,0
Sync
Text 0,0,"Heading For Waypoint: "+Str$(NextFlag)
loop
My alterations use basically the same waypoint, but place red objects at the random waypoint positions.
You'll also see that I've replaced your block of If and then's with a single 'If CurrentFlag > 1'.
Object Hit returns the number of the waypoint you bump into and you can use this number to calculate the number of the next waypoint - and thus the element of the array to get that waypoint's X and Z location to point the cube at.
The waypoints are objects 2, 3, 4 and 5, so if Object Hit returns a 3 then we know that the next waypoint is object 4.
The cube is object 1, so if any value greater than 1 is returned then we have reached a waypoint. If the 'NextFlag' is 6 then it doesn't exist so we set it to the first waypoint which is object 2.
If you remove the Rem on line 16, the waypoints are invisible, but until you know it works, it's useful to be able to see them.
TDK_Man