I've got the script for pointing towards a set of co-ordinates. But something strange is happening:
when gf clicked set [delta x v] to ((item [1 v] of [xlocations v]) - (x position)) set [delta y v] to ((item [1 v] of [ylocations v]) - (y position)) if <(delta y) = (0)> if <(delta x) = (0)> set [ideal direction v] to (-90) else set [ideal direction v] to (90) end else if <(delta y) < (0)> set [ideal direction v] to (180 + ([atan v] of ((delta x) / (delta y)))) else set [ideal direction v] to ([atan v] of ((delta x) / (delta y))) endI have a turning script after that.
Offline
I see no reason why it would keep rotating, there must be some other script causing interference. This script seems like it works properly.
Offline
You should switch the top value to (atan(x/y) - 180) so that it matches up with Scratch's system of degrees, which goes from -180 to 180 instead of from 0 to 360.
Offline
Wes64 wrote:
I see no reason why it would keep rotating, there must be some other script causing interference. This script seems like it works properly.
Don'[t worry, I fixed it
Last edited by zammer990 (2012-07-22 19:41:51)
Offline
why not create another sprite with a single pixel costume - hide it - make your other sprite point towards it in a forever loop - now simply move the hidden sprite to the desired co-ordinates and the visible sprite will follow the hidden one without all the maths?
Offline
Closed by request.
Offline