Drop Object Back Of Vehicle
#1

Hey, i wanna know, if i pressed <KEY_FIRE> a object should drop back of playerid vehicle.
But the x and y position changes when we make turn, how should i make it the same??
Can't figure out, help pls.

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if (PRESSED(KEY_FIRE))
    {
        new currentveh;
        currentveh = GetPlayerVehicleID(playerid);

        new Float:vehx, Float:vehy, Float:vehz;
        GetVehiclePos(currentveh, vehx, vehy, vehz); //x+0.13 y-5.30 z+0.27
        CreateObject(1518,vehx+0.13,vehy-5.30,vehz,0.00000000,0.00000000,0.00000000); //object(barrel4) (1)
    }
    return 1;
}
Reply
#2

GetVehicleZAngle? idk


also might be possible with

GetVehicleRotationQuat

but u try and figure that one out!
Reply
#3

But to create object we dont need floatz.
It works on some calculation and i m not perfect in maths.. :/
Reply
#4

pawn Код:
stock GetXYBehindPoint(Float:x,Float:y,&Float:x2,&Float:y2,Float:angle,Float:distance)
{
    x2 = x - (distance * floatsin(-angle,degrees));
    y2 = y - (distance * floatcos(-angle,degrees));
}
Try this stock.
Reply
#5

Thanks but it did'nt worked out..
anyone help appreciated!

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if (PRESSED(KEY_FIRE))
    {
        /*if (IsPlayerInAnyVehicle(playerid))
        {
            AddVehicleComponent(GetPlayerVehicleID(playerid), 1010);
        }*/

        new currentveh;
        currentveh = GetPlayerVehicleID(playerid);

        new Float:vehx, Float:vehy, Float:vehz, Float:distance, Float:angle, Float:x2, Float:y2;
        GetVehiclePos(currentveh, vehx, vehy, vehz); //x+0.13 y-5.30 z+0.27
        GetVehicleDistanceFromPoint(currentveh, vehx, vehy, vehz);
        GetVehicleZAngle(currentveh, angle);
        GetXYBehindPoint(vehx, vehy, x2, y2, angle, distance);
        CreateObject(1225,x2,y2,vehz,0.00000000,0.00000000,0.00000000); //object(barrel4) (1)
    }
    return 1;
}
stock GetXYBehindPoint(Float:x,Float:y,&Float:x2,&Float:y2,Float:angle,Float:distance)
{
    x2 = x - (distance * floatsin(-angle,degrees));
    y2 = y - (distance * floatcos(-angle,degrees));
}
Reply
#6

Instead of creating a variable for distance you should type the distance you would like the object to be created in.

Like this:

pawn Код:
GetXYBehindPoint(vehx, vehy, x2, y2, angle, 5);
CreateObject(1225,x2,y2,vehz,0.00000000,0.00000000,0.00000000);
That would create the object 5 units behind the car.
Reply
#7

Thanks my frnd reputation + for bth
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)