Calculating xangle? (rotx) ?
#1

pawn Code:
stock GetXYInFrontOfVehicle(vehicleid, &Float:x, &Float:y, [b]Float:xangle[/b], Float:distance)
{
    new Float:a;
    GetVehiclePos(vehicleid, x, y, a);
    GetVehicleZAngle(vehicleid, a);
    x += (distance * floatsin(-a, degrees));
    y += (distance * floatcos(-a, degrees));
}
does anyone know how to add a xrotation calculation to this>?
Reply
#2

What do you mean xangle?
Reply
#3

like this

http://forum.sa-mp.com/showthread.ph...ehiclerotation

Danger's one

xangle = heading / sideways
zangle = facing angle / bank

get what I mean?

now i got the xangle, but now I need to calculate infront of the vehicle with xangle..

xangle =
Reply
#4

bumpt.. been 24 hours ^^
Reply
#5

I must bump <.<
Reply
#6

may i ask what you intend to do? like an artillery rocket aiming, while standing on the ground? or something like in a plane? if your vehicle (tank, artillery) stands on grond, it is possible maybe to do that without using the (bugged) quaternion formulas. its just 2 axis (x/z) used for an "aditional x" you requested, so i look forward to get some1 to work on this aswell :P
Reply
#7

This'll be a epic thing I must know, bump!
Reply
#8

You also need the z-coordinate I think
Reply
#9

pawn Code:
stock RotatePoint(& Float: X, & Float: Y, & Float: Z, Float: pitch, Float: yaw, Float: distance) {
    X -= (distance * floatcos(pitch, degrees) * floatsin(yaw, degrees));
    Y += (distance * floatcos(pitch, degrees) * floatcos(yaw, degrees));
    Z += (distance * floatsin(pitch, degrees));
}
pawn Code:
stock GetXYZOfVehicle(vehicleid, & Float: X, & Float: Y, & Float: Z, Float: pitch, Float: distance) {
    static
        Float: yaw;
    if(GetVehicleZAngle(vehicleid, yaw)) {
        GetVehiclePos(vehicleid, X, Y, Z);
        RotatePoint(X, Y, Z, pitch, yaw, distance);
        return true;
    }
    return false;
}
Reply
#10

ok, I changed my code

pawn Code:
//new Float:x2 = x + (120 * floatsin(-(a + 90), degrees));
                        //new Float:y2 = y + (120 * floatcos(-(a + 90), degrees));
to

pawn Code:
new Float:x2, Float:y2, Float:z2, Float:heading, Float:attitude, Float:bank;
                        GetVehicleRotation(id, heading, attitude, bank);
                        GetXYZOfVehicle(id, x2, y2, z2, heading/*pitch*/, 120.0);
                        #pragma unused z2
                        #pragma unused attitude
                        #pragma unused bank
yet it doesn't work, I can't exactly tell what's happening. as soon as I shoot my missile exploded, it did no explode instantly with my previous code.. and I have a check to see if it's your vehicle the missile shot from it should not even check that vehicle..

I'll try to figure out where the missile comes out from this time

Edit: ok one, it doesn't work
two, if your turned around, at around 160 - 200 z angle, it fires out behind lol, it worked infront with the previous code
Reply
#11

Ding, wrong variable

heading is the ZAngle (Yaw)
attitude is the Roll Angle
bank is the Pitch Angle

And than you forgot GetVehiclePos

Here your wanted code
pawn Code:
new Float:x2, Float:y2, Float:z2, Float:bank;
GetVehicleRotation(id, x2, y2, bank);
GetVehiclePos(id, x2, y2, z2); // dont change the order!
GetXYZOfVehicle(id, x2, y2, z2, bank, 120.0);
Reply
#12

okay thanks, now it shoots fine. but the missile still doesn't go where the vehicle x angle / z is looking at (the hood of the car) I will pm you the code
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)