Hi all,

I'm trying to turn an entity around its axis smoothly. It is supposed to turn towards another entity and take the shortest rotation direction.
Here is some code:
Code:
vec_set(temp, my.x);
	vec_sub(temp, vector(mein_ziel_ptr.x,mein_ziel_ptr.y,mein_ziel_ptr.z+mein_ziel_ptr.gegner_hoehe));
	vec_to_angle(temp_angle, temp);
	if((temp_angle.pan-90)%360 < auge.pan%360 && (temp_angle.pan-90)%360 > (auge.pan - 180)%360){
		auge.pan += 2*time_step;
	}
	if((temp_angle.pan-90)%360 > auge.pan%360 && (temp_angle.pan-90)%360 <= (auge.pan + 180)%360){
		auge.pan -= 2*time_step;
	}
The "auge"-entity is the one that should rotate and "mein_ziel_ptr" is the one that should be faced.
I just don't understand how to work right with the modulo operator and how to avoid problems when the angle is negative...

Help is apreciated!

THX!!!


GameStudio Version: A7 Pro v7.86