Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
2 registered members (AndrewAMD, TipmyPip), 12,400 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 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 | 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