I was trying to get an object to point at another object while using Curveangle (to prevent lag time lag.) After fighting for a while with ATANFULL for a few days I gave up and switched to a not so pretty method of obtaining the angle. Finally it works as
Make Object Cube 1,5
Make Object Cube 2,10
Position object 2, 0, 40, 100
Turret_Speed = 1000
sync on
do
`Remember the original angle so we can use it in the curveangle function.
OldAngleX# = Object Angle X(1)
OldAngleY# = Object Angle Y(1)
OldAngleZ# = Object Angle Z(1)
`Point object 1 at object 2 so that we can get the destination angle.
Point Object 1,object position x(2),object position y(2), object position z(2)
DestinationAngleX# = Object Angle x(1)
DestinationAngleY# = Object Angle y(1)
DestinationAngleZ# = Object Angle z(1)
`Rotate Object 1 the interpolated amount between the Original Angle and the Destination Angle.
Rotate Object 1, CURVEANGLE(DestinationAngleX#,OldAngleX#,Turret_Speed), CURVEANGLE(DestinationAngleY#,OldAngleY#,Turret_Speed),CURVEANGLE(DestinationAngleZ#,OldAngleZ#,Turret_Speed)
`Used to move the box around and test the turret motion.
if upkey() then move object UP 2, .05
if downkey() then move object DOWN 2, .05
if leftkey() then move object left 2, .05
if rightkey() then move object right 2, .05
Sync
loop
Basically I was using something like this:
DistX# = Object Position X (Ship) - Object Position X (Selected_Target)
DistY# = Object Position Y (Ship) - Object Position Y (Selected_Target)
DistZ# = Object Position Z (Ship) - Object Position Z (Selected_Target)
TargetX# = ATANFULL(DistX#,DistZ#)
TargetY# = ATANFULL(DistY#,DistZ#)
TargetZ# = ATANFULL(DistX#,DistY#)
XROTATE OBJECT Ship,CURVEANGLE(TargetY#,OBJECT ANGLE X(Ship),Ship_Turn_Speed#)
YROTATE OBJECT Ship,CURVEANGLE(TargetX#,OBJECT ANGLE Y(Ship),Ship_Turn_Speed#)
What was I doing wrong? I'd rather use the ATANFULL function as I'm sure this is more efficient. Thanks
Wannabe Game Designer. Wannabe Programmer. Expert Dreamer.
Long Island Amateur Game Development Group http://www.meetup.com/LIAGDG/