20.09.2009, 07:36
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:
Can be Also.
(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:
EX:
X1 = 250.5;
Y1 = -430.625;
X2 = 246.741226;
Y2 = -429.256927;
Distance = floatabs(X2-X1)+floatabs(Y2-Y1);
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.
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
Код:
X1+(Distance*floatsin(-A,degrees)) = X2 Y1+(Distance*floatcos(-A,degrees)) = Y2
(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
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
calculation which will give me the Float of the Rotation.