SA-MP Forums Archive
Get Rotation X according angle player? - 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: Get Rotation X according angle player? (/showthread.php?tid=417296)



Get Rotation X according angle player? - HitnKill - 20.02.2013

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?


Re: Get Rotation X according angle player? - Babul - 20.02.2013

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.


Re : Get Rotation X according angle player? - HitnKill - 20.02.2013

I tried but he dont work.

PHP код:
Angle=  new Float:Angle;
GetPlayerFacingAngle(playeridAngle);
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.


Re : Get Rotation X according angle player? - HitnKill - 20.02.2013

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

PHP код:
Float:PointAngle(playeridFloat:xaFloat:yaFloat:xbFloat:yb

    new 
Float:carangle
    new 
Float:xcFloat:yc
    new 
Float:angle
    
xc floatabs(floatsub(xa,xb)); 
    
yc floatabs(floatsub(ya,yb)); 
    if (
yc == 0.0 || xc == 0.0
    { 
        if(
yc == && xc 0angle 0.0
        else if(
yc == && xc 0angle 180.0
        else if(
yc && xc == 0angle 90.0
        else if(
yc && xc == 0angle 270.0
        else if(
yc == && xc == 0angle 0.0
    } 
    else 
    { 
        
angle atan(xc/yc); 
        if(
xb xa && yb <= yaangle += 90.0
        else if(
xb <= xa && yb yaangle floatsub(90.0angle); 
        else if(
xb xa && yb >= yaangle -= 90.0
        else if(
xb >= xa && yb yaangle floatsub(270.0angle); 
    } 
    
GetVehicleZAngle(GetPlayerVehicleID(playerid), carangle); 
    return 
floatadd(angle, -carangle); 

Wrong Rotation isnt X but thanks you.