SA-MP Forums Archive
Trying to make opposite GetXYInFrontOfPlayer - get Rotation - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Trying to make opposite GetXYInFrontOfPlayer - get Rotation (/showthread.php?tid=98305)



Trying to make opposite GetXYInFrontOfPlayer - get Rotation - PoWerZ - 20.09.2009

I'm trying to make the opposite of GetXYInFrontOfPlayer.
I have 4 floats, 2 of the player XY and 2 of the XY Infront of the player view and i want to get the Rotation of the player.(Player is just example,it can be object vehicle and etc..).
I subtract each X from other X and same with Y,make them positive(absolute value of a float[EX:from -1.3 to 1.3]) and then i sum them and get the distance.
so far we have player pos,xyinfrontofplayer and distance.
then i want to make some equation;
Orginial:
Код:
X +=(Distance*floatsin(-A,degrees)); //X infront player after some Distance
Y +=(Distance*floatcos(-A,degrees)); //Y infront player after some Distance
Can be Also.
Код:
X1+(Distance*floatsin(-A,degrees)) = X2
Y1+(Distance*floatcos(-A,degrees)) = Y2
(X1 = PlayerPos X,X2 = X infront of player view)
(Y1 = PlayerPos Y,Y2 = X infront of player view)

I want to get the Rotation of the player so i remake the equation To this:
Код:
floatsin(-A,degrees) = (X2-X1)/Distance
floatcos(-A,degrees) = (Y2-Y1)/Distance
EX:
X1 = 250.5;
Y1 = -430.625;
X2 = 246.741226;
Y2 = -429.256927;
Distance = floatabs(X2-X1)+floatabs(Y2-Y1);
Код:
floatsin(-A,degrees) = (246.741226-250.5)/Distance
floatcos(-A,degrees) = (-429.256927-(-430.625))/Distance
from this part I don't know how to continue the equation and how to place the sin(or cos)
calculation which will give me the Float of the Rotation.



Re: Trying to make opposite GetXYInFrontOfPlayer - get Rotation - NeRoSiS - 20.09.2009

https://sampwiki.blast.hk/wiki/GetPlayerFacingAngle

Is that what your trying to make?


Re: Trying to make opposite GetXYInFrontOfPlayer - get Rotation - PoWerZ - 20.09.2009

Quote:
Originally Posted by Wazza!
https://sampwiki.blast.hk/wiki/GetPlayerFacingAngle

Is that what your trying to make?
No,
2 things:
1)I'm trying to set float,by caculating variables.
2)Player can be an example,I'm just trying to set his(EX:its - for objects) facing angle by checking his xy position and the xy position SOMEWHERE.
EX:Player/object is at LV and i do command which change his float:angle to look on some XY.(I don't know the float angle and trying to get it by an equation)


Re: Trying to make opposite GetXYInFrontOfPlayer - get Rotation - yom - 20.09.2009

Search for GetCoordsOnLine3D.


Re: Trying to make opposite GetXYInFrontOfPlayer - get Rotation - PoWerZ - 20.09.2009

Quote:
Originally Posted by 0rb
Search for GetCoordsOnLine3D.
Again,
this isn't what i'm asking for,
I want to set float:angle to player/object by checking their xy and the target xy,
and AGAIN EX:Me and my friend in area51 he is somewhere,I get his xy and my xy
and i want set my angle to the side he comes from.(i don't want to make any marker or something like that)


Re: Trying to make opposite GetXYInFrontOfPlayer - get Rotation - yom - 20.09.2009

Ahh sorry i misunderstood. Try this http://forum.sa-mp.com/index.php?top...6416#msg636416