Facing Angle Question [+REP]
#1

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?
Reply
#2

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
Reply
#3

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!
Reply
#4

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)