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(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.
Reply
#4

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)