Using Theodis' alt movement demo, the object can be facing any one of 360 directions. That's great. Now I've got a proc that can find the direction one object is from another, and that's great too. Now I need a way to find out which direction an object would have to turn towards another object in order to turn the shortest direction possible.
So, you have one number which is the object's current direction, and another number which is the direction that it wants to be facing. It needs to find out which direction, left or right, is the shortest turn to be facing the desired direction. Each value is of course between 0 to 359. I'm not sure how to make it work using numbers from 10 to 340, for example. It's only 30 from 10 to 340, but comparing the numbers, 340 seems pretty far away.
Solutions?
ID:153783
![]() Jan 28 2003, 6:26 pm
|
|
So basically, you want to subtract the desired direction from the current direction, but do so in a way that restricts the number from -180 to 180?
Assuming you stick with directional convention and go with positive being clockwise (as in my proc and I assume Theodis's as well), then this can actually be done with modulo:
Lummox JR