Get Rotation X according angle player?
#1

Hi i want to get the Rotation X for a object according the player angle, but i dont know how to do this calculation, its possible?
Reply
#2

the asin() and acos() functions will give you the results you need. besides the angle, you also need a radius. if you set the radius to 1.0, then the X-and Y-results will ne normalized.
Reply
#3

I tried but he dont work.

PHP код:
Angle=  new Float:Angle;
GetPlayerFacingAngle(playerid, Angle);
X to point = -1412.1890 
Y to point 
= 2351.3638
My calcul 
= -1412.1890 * acos(Angle) - 2351.3638 * asin(Angle) 
Its wrong, i have an error with this calcul.
Reply
#4

https://sampforum.blast.hk/showthread.php?tid=219539

PHP код:
Float:PointAngle(playerid, Float:xa, Float:ya, Float:xb, Float:yb) 
{ 
    new 
Float:carangle; 
    new 
Float:xc, Float:yc; 
    new 
Float:angle; 
    
xc = floatabs(floatsub(xa,xb)); 
    
yc = floatabs(floatsub(ya,yb)); 
    if (
yc == 0.0 || xc == 0.0) 
    { 
        if(
yc == 0 && xc > 0) angle = 0.0; 
        else if(
yc == 0 && xc < 0) angle = 180.0; 
        else if(
yc > 0 && xc == 0) angle = 90.0; 
        else if(
yc < 0 && xc == 0) angle = 270.0; 
        else if(
yc == 0 && xc == 0) angle = 0.0; 
    } 
    else 
    { 
        
angle = atan(xc/yc); 
        if(
xb > xa && yb <= ya) angle += 90.0; 
        else if(
xb <= xa && yb < ya) angle = floatsub(90.0, angle); 
        else if(
xb < xa && yb >= ya) angle -= 90.0; 
        else if(
xb >= xa && yb > ya) angle = floatsub(270.0, angle); 
    } 
    
GetVehicleZAngle(GetPlayerVehicleID(playerid), carangle); 
    return 
floatadd(angle, -carangle); 
} 
Wrong Rotation isnt X but thanks you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)