Problem with getting coords in front of my vehicle -
Mariuszowski - 24.05.2015
Hello, I had been doing a system in which you basically get into any vehicle and press FIRE and 2 rockets launch straight forward (I'm using GetXYInFrontOfPlayer). If I'm standing normally on the ground rockets move (MoveObject) towards xy in front of my vehicle but if I'm standing like
this rockets are not moving into the air. I can tell that the problem is in Z coordinate. See how my rocket is rotated here
picture. It's facing xy but it's facing wrong Z, what should I use to get that Z in front of me?
Re: Problem with getting coords in front of my vehicle -
shadowdog - 24.05.2015
Look at this:
https://sampwiki.blast.hk/wiki/GetVehicleRotationQuat
One of this is your rotation in the first picture (I haven't checked which one it is). Calculate the Z angle of the new position with an inversed TAN.
Re: Problem with getting coords in front of my vehicle -
Mariuszowski - 25.05.2015
Let's say that my rotation is W (I haven't found it yet) what would the formula for calcutating Z angle with TAN be?
I must admit I'm not much of a math guy.
Re: Problem with getting coords in front of my vehicle -
shadowdog - 25.05.2015
Take this function from Stepashka. It converts quats to degrees to use.
Quote:
Originally Posted by Stepashka
must live simply!!!
PHP код:
stock GetVehicleRotation(vehicleid,&Float:x,&Float:y,&Float:z) { new Float:quat_w,Float:quat_x,Float:quat_y,Float:quat_z; GetVehicleRotationQuat(vehicleid,quat_w,quat_x,quat_y,quat_z); x = atan2(2*((quat_x*quat_y)+(quat_w+quat_z)),(quat_w*quat_w)+(quat_x*quat_x)-(quat_y*quat_y)-(quat_z*quat_z)); y = atan2(2*((quat_y*quat_z)+(quat_w*quat_x)),(quat_w*quat_w)-(quat_x*quat_x)-(quat_y*quat_y)+(quat_z*quat_z)); z = asin(-2*((quat_x*quat_z)+(quat_w*quat_y))); return 1; }
|
This will return the x,y,z rotations of the vehicle in degrees. With this you can calculate the rocket's rotation.
Now use one of theses ( again i haven't checked which) in the following code:
PHP код:
Vertical Distance = <Horizontal Distance> * floattan( <W in degrees> , degrees);
Fill in the < and > parts. And it should return your vertical change in distance.
Re: Problem with getting coords in front of my vehicle -
Mariuszowski - 25.05.2015
This is very frustrating task. I got x y and z from GetVehicleRotation and what am I putting here <Horizontal Distance> what is that? What am I putting here <W in degrees> is it x y or z which I got from function or qW, qX, qY, qZ from GetVehicleRoationQuat?
Re: Problem with getting coords in front of my vehicle -
shadowdog - 25.05.2015
This is indeed very confusing, I struggled with a similar problem recently. I will try to explain the best I can.
<W in degrees> goes for the X, Y, Z which you get from the function I sent you.
The horizontal distance stands for the distance the rockets are going to travel on 'ground level' with that you can calculate the vertical distance aswell.