vehicle facing angle
#1

Hello!

I have this, it gets "GetVehiclePos" and "VehicleZAngle"
CODE:
pawn Код:
VehicleFire[id] = 1;

                        if(IsValidObject(VehicleBomb[id][0]))
                        {
                            DestroyObject(VehicleBomb[id][0]);

                            GetVehiclePos(id,x,y,z);
                            GetVehicleZAngle(id,a);

                            a += 270;
                            z += VehicleOffsetZ[id];

                            x += (VehicleOffsetX[id] * floatsin(-a, degrees));
                            y += (VehicleOffsetX[id] * floatcos(-a, degrees));

                            VehicleBomb[id][0] = CreateObject(3790,x,y,z,2,0,a,300.0);
                            VehicleSmok[id][0] = CreateObject(18731,x,y,z-1.3,0,0,0,300.0);

                            a += 90;

                            x += (300 * floatsin(-a, degrees));
                            y += (300 * floatcos(-a, degrees));

                            MoveObject(VehicleBomb[id][0],x,y,z,MISSILE_SPEED);
                            MoveObject(VehicleSmok[id][0],x,y,z-1.3,MISSILE_SPEED);

                            SetTimerEx("VM_Explode",MISSILE_DETONATE_TIME,0,"dd",id,0);
                            VM_OnVehicleFire(id,0);
                            return 1;
                        }
                        DestroyObject(VehicleBomb[id][1]);

                        GetVehiclePos(id,x,y,z);
                        GetVehicleZAngle(id,a);

                        a += 90;
                        z += VehicleOffsetZ[id];

                        x += (VehicleOffsetX[id] * floatsin(-a, degrees));
                        y += (VehicleOffsetX[id] * floatcos(-a, degrees));

                        VehicleBomb[id][1] = CreateObject(3790,x,y,z,2,0,a+180,300.0);
                        VehicleSmok[id][1] = CreateObject(18731,x,y,z-1.3,0,0,0,300.0);

                        a += 270;

                        x += (300 * floatsin(-a, degrees));
                        y += (300 * floatcos(-a, degrees));

                        MoveObject(VehicleBomb[id][1],x,y,z,MISSILE_SPEED);
                        MoveObject(VehicleSmok[id][1],x,y,z-1.3,MISSILE_SPEED);

                        SetTimerEx("VM_Explode",MISSILE_DETONATE_TIME,0,"dd",id,1);
                        VM_OnVehicleFire(id,1);
But how do i get the facing angle of the vehicles front? i mean if you facing up/down etc?
I want the objects also to move up and down depending on your vehicle front facing angle so the objects don't just moves straight from your position.
Reply
#2

Anyone who have any idea?
Reply
#3

You would need to use GetVehicleRotationQuat
But since its very advanced maths I cant help you with that

The best thing I would suggest is to search through this forum for a function that converts quat to euler angles
Reply
#4

pawn Код:
stock IsVehicleUpsideDown(vehicleid)
{
    new Float:quat_w,Float:quat_x,Float:quat_y,Float:quat_z;
    GetVehicleRotationQuat(vehicleid,quat_w,quat_x,quat_y,quat_z);
    new Float:y = atan2(2*((quat_y*quat_z)+(quat_w*quat_x)),(quat_w*quat_w)-(quat_x*quat_x)-(quat_y*quat_y)+(quat_z*quat_z));
    return (y > 90 || y < -90);
}
This can be somewhat useful for your work planned, enjoy...
Reply
#5

Quote:
Originally Posted by Nero_3D
Посмотреть сообщение
You would need to use GetVehicleRotationQuat
But since its very advanced maths I cant help you with that

The best thing I would suggest is to search through this forum for a function that converts quat to euler angles
Yeah i was looking on that Quat, but i didn't understand a thing about it. And im not that good at math nor.
Reply
#6

Quote:
Originally Posted by Lorenc_
Посмотреть сообщение
pawn Код:
stock IsVehicleUpsideDown(vehicleid)
{
    new Float:quat_w,Float:quat_x,Float:quat_y,Float:quat_z;
    GetVehicleRotationQuat(vehicleid,quat_w,quat_x,quat_y,quat_z);
    new Float:y = atan2(2*((quat_y*quat_z)+(quat_w*quat_x)),(quat_w*quat_w)-(quat_x*quat_x)-(quat_y*quat_y)+(quat_z*quat_z));
    return (y > 90 || y < -90);
}
This can be somewhat useful for your work planned, enjoy...
Thanks!
Is this just a part of what i need or is this enough to use for the plans?
Reply
#7

Anyone who can help me with this? ^^
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)