SA-MP Forums Archive
[HELP] Spawn ramps in front of vehicle - 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: [HELP] Spawn ramps in front of vehicle (/showthread.php?tid=249437)



[HELP] Spawn ramps in front of vehicle - JackYack13 - 18.04.2011

Hello. I'm trying to make something like when you press KEY_ACTION in a vehicle, a ramp will be created in front of you. Here's the part of my code that creates the ramp:
pawn Код:
new Float:x, Float:y, Float:z, Float:a;
GetVehiclePos(vehicleID, x, y, z);
GetVehicleZAngle(vehicleID, a);
ramp[playerid] = CreateDynamicObject(1655, x+(floatmul(20, floatsin(-a, degrees))), y+(floatmul(20, floatcos(-a, degrees))), z - 0.3, 0.0, 0.0, a, -1, -1, -1, DIST);
The problem is that this only makes the ramp in front of the vehicle when it's on flat ground. I decided to make some drawings for you so it's easier to understand (I guess could do better lol)

That's what I have right now:

/imageshack/img88/5650/rampsbad.png

That's what I want to have:

/imageshack/img218/6373/ramps.png

So basically I want the ramp to have the same pitch, yaw and roll angles as the vehicle and make it right in front of the vehicle no matter what its rotation on any axis is. I know this will have something to do with GetVehicleRotationQuat but... That stuff is magic for me ;P
So, could anyone help?


Re: [HELP] Spawn ramps in front of vehicle - JackYack13 - 19.04.2011

3rd page.. bump


Re: [HELP] Spawn ramps in front of vehicle - Sinner - 19.04.2011

This is advanced maths (youll need to use atan), try drawing it on paper so it'll be easier to figure out the calculations.


Re: [HELP] Spawn ramps in front of vehicle - JackYack13 - 19.04.2011

I think I got it already I found a function which converts quaternion angles into xyz angle values. The rest was pretty much piece of cake ;P