CPRLWon't Rotate a Core Towards A Targeted Position

Started by Jacobwde12, November 25, 2015, 10:20:01 PM

Previous topic - Next topic

Jacobwde12

Hey Guys! I tried to use a modified version of the Harvester Script from Farbor to try and create a rotating object, but it's not working for me. The object just moves insteads of rotating. Anyone know how to fix this?
# Stealth Fighter Movement.crpl
# Created on: 11/25/2015 12:29:11 PM
# ------------------------------------------
$rotateSpeed:0.1

# Setup an initial movement. 
once
    RandCoords ->targetX ->targetY
CurrentCoords ->y ->x
<-targetX sub(<-x) ->dx
<-y sub(<-targetY) ->dy
atan2(<-dy <-dx) ->targetAngle
GetImageRotation(Self "Main") ->currentAngle
ShortestAngle(<-currentAngle <-targetAngle) ->shortestAngle
if (abs(<-shortestAngle) lt (<-rotateSpeed))
SetImageRotation(Self "Main" <-targetAngle)
else
if (<-shortestAngle lt(0))
<-currentAngle sub(<-rotateSpeed) ->currentAngle
else
<-currentAngle add(<-rotateSpeed) ->currentAngle
endif
SetImageRotation(Self "Main" <-currentAngle)
endif
<-targetX <-targetY swap 2 QueueMove
endonce

# If the current movement queue is empty, pick a new spot to move to.

GetQueuedMoveCount eq0 if
    RandCoords ->targetX ->targetY
CurrentCoords ->y ->x
<-targetX sub(<-x) ->dx
<-y sub(<-targetY) ->dy
atan2(<-dy <-dx) ->targetAngle
GetImageRotation(Self "Main") ->currentAngle
ShortestAngle(<-currentAngle <-targetAngle) ->shortestAngle
if (abs(<-shortestAngle) lt (<-rotateSpeed))
SetImageRotation(Self "Main" <-targetAngle)
else
if (<-shortestAngle lt(0))
<-currentAngle sub(<-rotateSpeed) ->currentAngle
else
<-currentAngle add(<-rotateSpeed) ->currentAngle
endif
SetImageRotation(Self "Main" <-currentAngle)
endif
   <-targetX <-targetY swap 1 QueueMove
endif