Rotation limits on a moving object

Posted By: Impaler

Rotation limits on a moving object - 11/28/07 08:00

Hi everyone,
In my 3D battleships game, I have a turret attached to the front and back of the ship, and need to prevent them from turning too far(see pic below).

[image][/image]
This is a problem because the ship can also turn seperate of the turret and get a rotation in the thousands of degrees because it overruns the 360 degree numerical rotation value. Because of this, I can't compare the turret's rotation to the ship's rotation and limit it's rotation properly. My script is:
Code:
  
vec_set(my.pan, your.pan);
my.pan += heading;
my.pan = max(my.pan, your.pan + 70);
my.pan = min(my.pan, your.pan + 290);



How can i change this to account for the fact that the value for the ships pan may be far greater than 360 degrees?
Posted By: Fenriswolf

Re: Rotation limits on a moving object - 11/28/07 08:42

Hi,

you can use ang for this.
Thus all your angles will be within the same range (-180 ... 180).
Posted By: Impaler

Re: Rotation limits on a moving object - 11/28/07 12:37

Thanks, fenriswolf, I didn't know about that before
© 2024 lite-C Forums