[HELP] Spawn ramps in front of vehicle
#1

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?
Reply
#2

3rd page.. bump
Reply
#3

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

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)