rem Vectors - OpenDBC tutorial (DarkBASIC Professional) sync on : sync rate 60 autocam off color backdrop rgb(14, 16, 28) rem Vectors live in numbered slots, like objects r = make vector3(1) : rem position of the chaser r = make vector3(2) : rem position of the target r = make vector3(3) : rem direction from chaser to target make object cone 1, 10 : color object 1, rgb(255, 120, 60) xrotate object 1, 90 : fix object pivot 1 make object sphere 2, 8 : color object 2, rgb(90, 220, 255) set vector3 1, 0, 0, 0 position camera 0, 55, -60 point camera 0, 0, 0 do t = wrapvalue(t + 1) rem The target moves on a figure of eight set vector3 2, sin(t) * 40, 0, sin(t * 2) * 20 position object 2, x vector3(2), y vector3(2), z vector3(2) rem direction = target - chaser, then normalised to length 1 subtract vector3 3, 2, 1 distance# = length vector3(3) normalize vector3 3, 3 rem Step 0.8 units along the direction unless already there if distance# > 5 multiply vector3 3, 0.8 add vector3 1, 1, 3 endif position object 1, x vector3(1), y vector3(1), z vector3(1) point object 1, x vector3(2), y vector3(2), z vector3(2) text 10, 10, "Distance: " + str$(distance#, 1) sync loop