<<Oops, I spelled paste wrong>>
Here is a function that works like the Point Towards Comand in EZ Rotate. It was made in the trial version of DB (I'm holding out 'till Christmas).
The Function:
Function Point_Towards(pointer, target, speed)
oldX# = object angle x(pointer)
oldY# = object angle y(pointer)
oldZ# = object angle z(pointer)
Point Object pointer, object position x(target), object position y(target), object position z(target)
newX# = object angle x(pointer)
newY# = object angle y(pointer)
newZ# = object angle z(pointer)
newX# = curveangle(newX#, oldX#, speed)
newY# = curveangle(newY#, oldY#, speed)
newZ# = curveangle(newZ#, oldZ#, speed)
zrotate object pointer, newZ#
yrotate object pointer, newY#
Xrotate object pointer, newX#
EndFunction
In an example:
sync on
sync rate 30
make object cube 1,1
make object box 2,1,1,3
move object 1,5
make matrix 9,50,50,20,20
position matrix 9,-25,-25,0
update matrix 9
position camera 0,10,-10
point camera 0,0,0
do
if leftkey() = 1 then turn object left 1,5
if rightkey()= 1 then turn object right 1,5
if upkey() = 1 then move object 1,0.25
point_towards(2, 1, 10)
sync
loop
Function Point_Towards(pointer, target, speed)
oldX# = object angle x(pointer)
oldY# = object angle y(pointer)
oldZ# = object angle z(pointer)
Point Object pointer, object position x(target), object position y(target), object position z(target)
newX# = object angle x(pointer)
newY# = object angle y(pointer)
newZ# = object angle z(pointer)
newX# = curveangle(newX#, oldX#, speed)
newY# = curveangle(newY#, oldY#, speed)
newZ# = curveangle(newZ#, oldZ#, speed)
zrotate object pointer, newZ#
yrotate object pointer, newY#
Xrotate object pointer, newX#
EndFunction
"There will always be evil, for, without evil, the good shall lose their virtue."