Hi all. I ALMOST have a working alternative to set cam to follow thus allowing for a speed variable to allow for timer based movement. the PROBLEM is it rotates wrong when the object turns and it doesn't zoom in to the object and slow down as it zooms in. it also doesn't slowly turn towards the object's rotation when initialized.
If someone could help me with this, I'd greatly appreciate it.
This is here for anyone who wants it
Here's the code:
Rem Project: trackingcamera
Rem Created: Sunday, December 19, 2010
Rem ***** Main Source File *****
sync on
sync rate 60
backdrop on
color backdrop RGB(0,61,128)
Make object box 1,1,1,1 `marker
`create target object
Make object box 2,10,10,10
color object 2,RGB(0,255,0)
set object light 2,1
`create some environment
For Deco=3 to 50
clone object Deco,2 : scale object Deco,50,50,50
color object Deco,RGB(255,0,255)
Position object Deco,RND(300),0,RND(300)
NEXT
`positioning camera and marker
position camera 0,-50,150,-50
position object 1,-50,150,-50
make vector3 1
`main loop
Do
move object 2, (keystate(17)-keystate(31) or upkey()-downkey())*1
turn object left 2, (keystate(30)-keystate(32) or leftkey()-rightkey())*1
x#=object position x(2) : y#=object position y(2) : z#=object position z(2)
cx#=camera angle x(0) : cy#=camera angle y(0) : cz#=camera angle z(0)
ox#=object angle x(1) : oy#=object angle y(1) : oz#=object angle z(1)
`point marker
point object 1,x#,y#,z#
`camera action
Rotate camera Curveangle(ox#,cx#,500.0),Curveangle(oy#,cy#,500.0),Curveangle(oz#,cz#,500.0)
`if dist from cam to object > ...
if GetDist(1,0,2,0)>150
`move camera towards object
point camera object position x(2), object position y(2), object position z(2)
move camera 1
endif
center text screen width()/2, screen height()/2, "dist:"+str$(GetDist(1,0,2,0))
Sync
LOOP
delete vector3 1
function GetDist(camon,cam,obj1,obj2)
select camon
case 0
if obj1<>0 and obj2<>0
x1#=Object Position X(obj2)
y1#=Object Position Y(obj2)
z1#=Object Position Z(obj2)
x2#=Object Position X(obj1)
y2#=Object Position Y(obj1)
z2#=Object Position Z(obj1)
endif
endcase
case 1
if obj1<>0
x1#=Camera Position X(cam)
y1#=Camera Position Y(cam)
z1#=Camera Position Z(cam)
x2#=Object Position X(obj1)
y2#=Object Position Y(obj1)
z2#=Object Position Z(obj1)
endif
endcase
endselect
dist# = Dist(x1#,x2#,y1#,y2#,z1#,z2#)
endfunction dist#
Function Dist(x1#,x2#,y1#,y2#,z1#,z2#)
Set Vector3 1,x1#-x2#,y1#-y2#,z1#-z2#
rdist#=Length Vector3(1)
EndFunction rdist#
Also, I created the distance functions
CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD AT Amazon.com!