|
|
HELP: Angle Problem
#205286
05/05/08 16:14
05/05/08 16:14
|
Joined: Jul 2004
Posts: 1,710
MMike
OP
Serious User
|
OP
Serious User
Joined: Jul 2004
Posts: 1,710
|
Hello.
I have this 2 action:
action rotate_ent1{ var p1;
while(1){ my.pan+=1*time; p1=my.pan; // p1 stores this pan. wait(1);} }
action rotate_ent2{ var p2;
while(1){ ang_rotate(my.pan,vector(1,0,0)); // adding the sameway pan guess p2=my.pan; // p1 stores this pan. wait(1);} }
THEN i have a panel, showing p1 and p2.. Now my problem is that, on ent 1 the pan will go from zero to 260 .. 450 etc etc.. and the p2 will go to 179 then.. turn -179..-150 .. -120. etc.. the other way .. Why?
Now if i have to points, and the angle p1 is 180 calculated from p2 , i want p2 to face p1, then a do c_rotate(me,vector(0.1,0,0),USE_AXISr|GLIDE); if the angle is < p1 but each time is turn 180 it will go negative other way, and my entity will rotate like a snake, right , left, right left, and can''t figure out this... I want to do a c_rotate(me,vector(0.1,0,0),USE_AXIS|GLIDE); and i can't because when it reaches the 180 degree, it will be counting back negative, thus confusing the if angle < angle target calculation, since if its not < it will be > and will c rotate the other way.. and never reach the right angle.
Last edited by MMike; 05/05/08 16:16.
|
|
|
Re: HELP: Angle Problem
[Re: MMike]
#205290
05/05/08 16:54
05/05/08 16:54
|
Joined: Jul 2004
Posts: 1,710
MMike
OP
Serious User
|
OP
Serious User
Joined: Jul 2004
Posts: 1,710
|
why does c_rotate or ang_add will turn my.pan just range from -180 to 180 ?
With further tests, i got this:
0º X------------->O
35999º X------------->O
You can point 0º or 360º its the same, but.. for the entity its not, since with 360º it will need to go back till 0º is reached, and will give a full rotation.
Now imagine this: You have the angle between p1(me) and p2(target) which is 20º ( calculated from vec_to_angle positions).
The my pan is 180º more from the target, so they are not facing each other. How do you turn to your target, add the angle or will reduce the angle so it reachs 20º and face the target? you could also add more, and it would be the same.. The problem is that when you turn, new calculations are made, and suddenty it says the angle is not 20º but 20-360º now, the entity will turn the other side, and over and over, and won't work.
<--X(me) O(target)
Last edited by MMike; 05/05/08 18:01.
|
|
|
|