GetXYZInfrontOfVehicle?
#1

Trying to come up with a stunt plane that fires exploding barrels.

Of course there is GetVehicleRotationQuat available to us, and I've seen it converted from Quaternion to Eulers, however although my math isn't too bad, these things are a little bit too advanced for me.

Here is a function I use the get the X/Y based on the input X/Y, that is at a certain angle/distance..
Код:
GetXYInFrontOfSpawn(&Float:x, &Float:y, Float: a, Float:distance)
{
	x += (distance * floatsin(-a, degrees));
	y += (distance * floatcos(-a, degrees));
}
I'd like to make something similar to that, it would use the planes pitch/roll/banking/whatever to give me not only x/y, but z also, so that I can put a distance of 10.0 to place the object, and 400.0 for where it is heading to, I was thinking the function should be structured as the following...
Код:
GetXYZInfrontOfVehicle(vid, &Float:x, &Float:y, &Float: Z, Float:distance)
... but how to achieve that, well that's why I'm here asking.

Thanks .
Reply
#2

pawn Код:
// GetXYInFrontOfVehicle by MrDeath

stock
    GetXYInFrontOfVehicle(vehicleid, &Float: x, &Float: y, Float: distance)
    {
        new
            Float: vehX,
            Float: vehY,
            Float: vehA
            ;

        GetVehiclePos(vehicleid, vehX, vehY, vehA);
        GetVehicleZAngle(vehicleid, vehA);

        x = vehX + (distance * floatsin(-vehA, degrees));
        y = vehY + (distance * floatcos(-vehA, degrees));
}
Reply
#3

You seem to have missed the point of the question. I'm trying to launch an object on a path based on the angle an aeroplane is facing , which is not just X/Y, but Z as well.

This can be achieved with GetVehicleRotQuat I believe.
Reply
#4

I tried using GetVehicleVelocity, which works in a way, but if the stunt plane is losing altitude due to rising too quickly or something to that nature, it obviously fires off in the direction you're travelling.

Any help on this would be greatly appreciated.
Reply
#5

Let's try and stay relevant here. His post wasn't even right for what this topic is about !
Reply
#6

Never said I did, and I didn't give you an attitude for posting, I just mentioned this thread isn't about that, and to stay on topic, so calm down and go enjoy the code you have found.
Reply
#7

Quote:
Originally Posted by [FU]Victious
Посмотреть сообщение
Oh im sorry, what ya gunna do about it?

I needed the code, and i thanked, got a fucking problem with that?
Oh wow your attitude surely sucks.

I would help if I was good at math, OP. :/
Reply
#8

Unfortunately some people get angry quickly on th internet.

Anyone able to help please?
Reply
#9

A simple forum search would show that a script was released for converting quaternions to eulers in which you can use those.....

http://forum.sa-mp.com/showthread.ph...ght=quaternion


[edit] after reading this thread and irc I made this function only to find out evo did and then betamaster before that xD ah well at least I learned something.....
Reply
#10

I don't know how to use those values to make a function like this.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)