Problem with "The Booster"
#1

Hey SAMP world!

I gotta little problem which some of you might not understand, but I hope you'll do

Allright, I am going to make booster using SetVehicleVelocity
Okay, let's do this!
pawn Код:
...
new BoostVal = 45;
SetVehicleVelocity(pVeh[PlayerId], BoostVal, BoostVal, BoostVal);
return 1;
}
Done? Eh, not actually.
This will add velocity to X,Y and Z axes of 45. Why it's not done? Because either car is turned of 36*° or 250*°, velocity will be added in direction of 45° to left side and 45° up.

It will look somehow like this (let's say, that vehicle is moving straight at Y axis)

+ - Vehicle way
/ - velocity vector

For X/Y axes:
Y
^
| +
| +
| +/
| *
|
+------------->X


It'll looks almost the same for Y/Z axes.

So it is not what I was talking about.
To set vector to be as same as vehicle rotation, I need to use this formula:
xBoost = actual velocity + BoostVal * sin(VehicleRot)
yBoost = actual velocity + BoostVal * cos(VehicleRot).

For example: actual X/Y velocity: 40, 50,
Vehicle Rot: 90°
xBoost = 40 + 45 * sin(90) = 40 + 45 * 1 = 85
yBoost = 50 + 45 * cos(90) = 50 + 0 = 50

.. And from the pattern you can get x/yBoost for any rotation (0°-360°)
Epic win, it works! Now if vehicle will have either rotation of 32° or 296°, velocity will "push" vehicle forward (if BoostVal < 0 then it will push vehicle backward)

.. but what if I wanna do this boost for JET, and it's Y/Z or X/Z slope isn't 0 degrees?
If jet is flying 25° down, then how to calculate zBoost?
zBoost = actual Z velocity + 45 * tg(35)?
If yes, then how to calculate if jet is flying at slope of 35°

Would be awesome, if someone responses.
Thanks a lot

Greetz,
LetsOWN
Reply
#2

If you use the Math Plugin by JernejL, you can use MPProjectPointOnVehicle to project a point ahead of the vehicle the player is in. From that you can deduce the vehicle's orientation and get the zBoost value to use with SetVehicleVelocity.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)