SA-MP Forums Archive
GetXYZInfrontOfVehicle? - 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: GetXYZInfrontOfVehicle? (/showthread.php?tid=182332)



GetXYZInfrontOfVehicle using GetVehicleRotationQuat? - Austin - 10.10.2010

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 .


Re: GetXYZInfrontOfVehicle? - MrDeath537 - 10.10.2010

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));
}



Re: GetXYZInfrontOfVehicle? - Austin - 10.10.2010

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.


Re: GetXYZInfrontOfVehicle? - Austin - 10.10.2010

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.


Re: GetXYZInfrontOfVehicle? - Austin - 10.10.2010

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


Re: GetXYZInfrontOfVehicle? - Austin - 10.10.2010

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.


Re: GetXYZInfrontOfVehicle? - CrucixTM - 10.10.2010

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. :/


Re: GetXYZInfrontOfVehicle? - Austin - 10.10.2010

Unfortunately some people get angry quickly on th internet.

Anyone able to help please?


Re: GetXYZInfrontOfVehicle? - cyber_punk - 10.10.2010

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.....


Re: GetXYZInfrontOfVehicle? - Austin - 11.10.2010

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