Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
3 registered members (AndrewAMD, Grant, Neb), 908 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 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