Facing Angle Question [+REP] - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Facing Angle Question [+REP] (
/showthread.php?tid=602190)
Facing Angle Question [+REP] -
vassilis - 03.03.2016
I want to make a small feature and i need player to set his angle automatically looking at object!
For example this picture:
Player - Player
^/>/< - Playe Angle(Just example to understand)
Better Explanation:
I want the player everytime he press the command to change angle and set player's angle(if his angle is not correct) looking at object how i could make it that?
In all 3 cases for example?
Re: Facing Angle Question [+REP] -
Jefff - 03.03.2016
pawn Код:
stock Float:AngleToPoint(Float:x,Float:y,Float:x1,Float:y1)
{
new Float:newang = atan(floatabs((x-x1)/(y-y1)));
if (x1 <= x && y1 >= y) newang += 90.0; //quadrant 2
else if (x1 < x && y1 < y) newang = -newang + 270.0; //quadrant 3
else if (x1 >= x && y1 <= y) newang += 270.0; //quadrant 4
else if (x1 > x && y1 > y) newang = 90.0 - newang; //quadrant 1
return newang;
}
http://forum.sa-mp.com/showthread.ph...topoint&page=3
Re: Facing Angle Question [+REP] -
vassilis - 03.03.2016
Quote:
Originally Posted by Jefff
pawn Код:
stock Float:AngleToPoint(Float:x,Float:y,Float:x1,Float:y1) { new Float:newang = atan(floatabs((x-x1)/(y-y1))); if (x1 <= x && y1 >= y) newang += 90.0; //quadrant 2 else if (x1 < x && y1 < y) newang = -newang + 270.0; //quadrant 3 else if (x1 >= x && y1 <= y) newang += 270.0; //quadrant 4 else if (x1 > x && y1 > y) newang = 90.0 - newang; //quadrant 1 return newang; }
http://forum.sa-mp.com/showthread.ph...topoint&page=3
|
Pretty efficient. Thank you!
Re: Facing Angle Question [+REP] -
AbyssMorgan - 04.03.2016
PHP код:
GetRotationFor2Point2D(Float:x,Float:y,Float:tx,Float:ty,&Float:rz);
GetRotationFor2Point3D(Float:x,Float:y,Float:z,Float:tx,Float:ty,Float:tz,&Float:rx,&Float:rz);
3DTryg.inc