Jump to content

PlayerPersecutor PhiAngle Limits?


photo

Recommended Posts

Hello,

 

I was using the PlayerPersecutor and setting the PhiAngle via setPhiAngle(float).

However, when I set it to a value < -180 or > 180 it overflows it into the opposite sign...

For example:

-190 = 10

190 = -10

 

While these angle are indeed coterminal...I did not find any documentation warning me of this behavior.

 

Also, I am using it in relation to the PlayerActor's phi angle .getPhiAngle()

PlayerActor's phi angle does not have this restriction. Thus, when I try to interpolate towards some angle relative to the actor's phi angle, it ends up spinning my camera around endlessly trying to reach the target angle.

 

Personally, I would prefer it if the persecutor could handle any angle that the actor can potentially have.

 

 

 

Thanks,

Michael

Link to comment

Recalculation of the Phi,Theta values occurs every get/set function call.

It means that the getThetaAngle/getPhiAngle function does not return you the same value (value that you set).

Link to comment

Recalculation of the Phi,Theta values occurs every get/set function call.

It means that the getThetaAngle/getPhiAngle function does not return you the same value (value that you set).

 

Okay, however as mentioned before, this does not seem to be the case with PlayerActor? Consequently, using the two classes together (which should be intended...) becomes a hassle as I try to convert angles to interface between the two. It also means I have to keep track of which direction the actor was turning in, to prevent the camera from taking "short cuts" using a counter-rotational direction to reach the target angle.

 

Can't you just provide an option to disable this "feature"?

Link to comment

Okay, however as mentioned before, this does not seem to be the case with PlayerActor? Consequently, using the two classes together (which should be intended...) becomes a hassle as I try to convert angles to interface between the two. It also means I have to keep track of which direction the actor was turning in, to prevent the camera from taking "short cuts" using a counter-rotational direction to reach the target angle.

 

Can't you just provide an option to disable this "feature"?

 

Anyways, it's a hassle, but I went ahead and just implemented the conversion and bounds checking needed to make it work. Makes code ugly :)

 

In any case, it would be a good idea to:

1) Be consistent

2) Document inconsistencies

 

In case anyone is curious how I chose to deal with this: (or perhaps can improve upon my method)

1) Compute first coterminal angle of opposite sign

2) Compute minimal coterminal angle of same sign

3) Rotate towards nearest computed coterminal angle where distance is abs(coterminal - camera)

 

When the PlayerPersecutor clamps the angle to -180:180, it will becomes nearer to the other coterminal angle, allowing it to continue rotation in the same direction.

 

This however will lose track of the direction of rotation if you make "too large" (without thinking too hard about this... greater than 180 degrees in a single frame) of movements. Though, in the case of simple camera rotation, per frame the change in angle is unlikely to encounter the issue. Hackish... but hey, it's already a hack.

Link to comment
×
×
  • Create New...