Rotation problem

Posted By: Altarius

Rotation problem - 03/06/13 16:07

Hi,

Im trying to rotate an entity following another one using this function:

vec_diff(temp,vtemp.x,my.x);
vec_to_angle(my.ang_pan,temp);
temp_ang.pan = ang(my.ang_pan - my.pan);

if(temp_ang.pan > 0)
{
my.pan += minv(5 * time_step,abs(temp_ang.pan));
}
if(temp_ang.pan < 0)
{
my.pan -= minv(5 * time_step,abs(temp_ang.pan));
}

Where "vtemp" are a entity snapped to the mouse using mouse_dir3d.
The camera.pan rotate whit the "my.entity".

So my problem is when i reach a pan angle of 90 degree my entity reverse is rotation.Probably cause the 180,-180...

Anyone know a way too fix that?
Thx.


Posted By: Superku

Re: Rotation problem - 03/06/13 17:27

vec_diff(temp,vtemp.x,my.x);
vec_to_angle(my.ang_pan,temp);
my.pan += clamp(ang(my.ang_pan-my.pan),-5,5)*time_step;

should do the trick.
© 2024 lite-C Forums