Hi
I am making a college project.Its like a Flight simulator.But i am stuck at the A.I. formation.
The thing is i need to rotate an object in 3d to point towards a point smoothly not just snapping but rotating.
My first attempt was to use Atanfull() but it made the plane flicker and go in wrong direction .i added and subtracted the angle by 180,360,90,270 but nothing worked.
So i had to learn to use vectors but it is still not working.
I think i am not making a good approach.
function angleystep(obj1,tar,speed#)
a=1
b=2
c=3
null=make vector3(a)
null=make vector3(b)
null=make vector3(c)
x1=object position x(obj1)
z1=object position z(obj1)
lx1=limb position x(obj1,4)
lz1=limb position z(obj1,4)
x2=object position x(tar)
z2=object position z(tar)
set vector3 b,x2-x1,0,z2-z1
normalize vector3 b,b
set vector3 a,lx1-x1,0,lz1-z1
normalize vector3 a,a
set vector3 c,0,1,0
angle#=acos(dot product vector3(a,b))
angle2#=acos(dot product vector3(b,c))
if angle2# < 90
angle3# = 360 - angle1#
else
angle3# = angle1#
endif
text 0,50,"angle="+str$(angle#)
text 0,60,"angle2="+str$(angle2#)
text 0,70,"new angle="+str$(angle3#)
endfunction
oh and one more thing it should be like a function.
ALLAH IS THE GREATEST
May he forgive me