I want a function that gives me the turn direction for my object (1
or -1
)
I have two angles
1 - current rotation(A)
0 <= A <= 360
2 - target rotation(B)
0 <= B <= 360
int turnSide = FindTurnSide(A, B);
Myobject.rotation += turnSpeed * turnSide;
public int FindTurnSide(int A, int B){
//Find the closest side direction for return
//return 1 for right side
//return -1 for left side
}
The function should find the closest side for turn. And it should return 1
(turn right) or -1
(turn left).
How can I implement the FindTurnSide
function?