Little math problem :-/ (hopefully not big)

Blitz3D Forums/Blitz3D Programming/Little math problem :-/ (hopefully not big)

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Not meaning to hijack this thread, but since there's some math majors here I got a little problem too.
This code was taken from the archives and the idea is it's supposed to aim and move your object towards a 3d point. It works most of the time but sometimes it doesn't, I think when it hits negative values or something. I suck at math so I'm not sure how to fix it to be 100% accurate.
For e=1 To 35
PointEntity enemy[e]\pivot,player
targetangle#=EntityYaw(cam,True)
currentangle#=EntityYaw(enemy[e]\pivot)

If Abs(currentangle#-targetangle#)<180 Then turn=2 Else turn=-2 
If currentangle#<targetangle# 
TurnEntity enemy[e]\pivot,0,turn,0 
Else
If currentangle>targetangle
TurnEntity enemy[e]\pivot,0,-turn,0
EndIf
EndIf
MoveEntity enemy[e]\pivot,0,-0.5,.5 
Next


Thanks