Trying to make opposite GetXYInFrontOfPlayer - get Rotation
#1

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


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)