Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, alibaba), 1,426 guests, and 9 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Rotating problems! #201834
04/11/08 12:32
04/11/08 12:32
Joined: Oct 2007
Posts: 116
S
sydan Offline OP
Member
sydan  Offline OP
Member
S

Joined: Oct 2007
Posts: 116
This has been a long standing problem with me. If you want an entity to face at something then you can use a 'vector to angle' function to set the 'pan' value to what to the desired direction but this doesn't really help. What I am trying to do is get the entity to actually turn, i.e. make the movement between its current pan and the dirrection I want it to face. I also need it to turn left if it would be quicker and right if quicker.

I currently use this
 Code:
		vec_set(temp,my.x);
		vec_sub(temp,you.x);
   		vec_to_angle(my.aim_pan,temp.x); // find the angle needed to face the target
   		//rotation catch up
      		if(my.aim_pan != my.pan) // check if it needs to turn, where aim_pan is the desired dirrection
      		{
      			my.pan += (my.aim_pan-(my.pan+180))/3*time; // if so turn
		}
 


But it is riddles with glitches, the entities will spin rapidly on the spot occationally and also if they are facing dirrectly away from their target they get stuck. Can anyone suggest a better method?


For some reason, my ambition always seems to beat my ability.
Re: Rotating problems! [Re: sydan] #202222
04/13/08 21:14
04/13/08 21:14
Joined: Jan 2007
Posts: 221
F
Fenriswolf Offline
Member
Fenriswolf  Offline
Member
F

Joined: Jan 2007
Posts: 221
Hello,

you could do something like this:

 Code:
vec_diff(vec_to_target, you.x, my.x); // direction vector from my to you
vec_to_angle(ang_to_target, vec_to_target); // get angles of direction vector

if (ang(ang_to_target.pan - my.pan) < 0) {
   my.pan -= 4 * time_step;
} else {
   my.pan += 4 * time_step;
}


The stuff in theconditional statement - ang(ang_to_target.pan - my.pan) - is the vital part, that calculates the difference between the pan angles of the my entity and the direction vector.

Re: Rotating problems! [Re: Fenriswolf] #212829
06/24/08 13:14
06/24/08 13:14
Joined: Jul 2004
Posts: 1,710
MMike Offline
Serious User
MMike  Offline
Serious User

Joined: Jul 2004
Posts: 1,710
i had one solution, it rotate the shortest angle to get the target point. quaternions optimization..


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