Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (Ayumi, 7th_zorro, 1 invisible), 1,060 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Rotation problem #419123
03/06/13 16:07
03/06/13 16:07
Joined: Jul 2009
Posts: 85
A
Altarius Offline OP
Junior Member
Altarius  Offline OP
Junior Member
A

Joined: Jul 2009
Posts: 85
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.



Last edited by Altarius; 03/06/13 16:08.
Re: Rotation problem [Re: Altarius] #419131
03/06/13 17:27
03/06/13 17:27
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
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.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1