wheel Trigometry
#3

This is a command that I made, it shows you an example of how you might find the coordinates you need to get an offset of the tires. This of course uses the function 'GetVehicleRelativePos' which is credited to Mauzen. First you need this stock:
pawn Код:
stock GetVehicleRelativePos(vehicleid, &Float:x, &Float:y, &Float:z, Float:xoff= 0.0, Float:yoff= 0.0, Float:zoff= 0.0)
{
    new Float:rot;
    GetVehicleZAngle(vehicleid, rot);
    rot = 360 - rot;
    GetVehiclePos(vehicleid, x, y, z);
    x = floatsin(rot, degrees) * yoff + floatcos(rot, degrees) * xoff + x;
    y = floatcos(rot, degrees) * yoff - floatsin(rot, degrees) * xoff + y;
    z = zoff + z;
}
Then you would use the following:
pawn Код:
new Float:x, Float:y, Float:z, Float:x2, Float:y2, Float:z2;
   
//For the front left tyre:
    GetVehicleModelInfo(GetVehicleModel(veh), VEHICLE_MODEL_INFO_WHEELSFRONT, x, y, z);
    GetVehicleRelativePos(veh, x2, y2, z2, -x - 0.5, y, z);
    SetPlayerCheckpoint(playerid, x2, y2, z2, 0.5);

//For the front right tyre...
    GetVehicleModelInfo(GetVehicleModel(veh), VEHICLE_MODEL_INFO_WHEELSFRONT, x, y, z);
    GetVehicleRelativePos(veh, x2, y2, z2, x + 0.5, y, z);
    SetPlayerCheckpoint(playerid, x2, y2, z2, 0.5);

//For the Back left tyre...
    GetVehicleModelInfo(GetVehicleModel(veh), VEHICLE_MODEL_INFO_WHEELSREAR, x, y, z);
    GetVehicleRelativePos(veh, x2, y2, z2, -x - 0.5, y, z);
    SetPlayerCheckpoint(playerid, x2, y2, z2, 0.5);

//For the Back right tyre...
    GetVehicleModelInfo(GetVehicleModel(veh), VEHICLE_MODEL_INFO_WHEELSREAR, x, y, z);
    GetVehicleRelativePos(veh, x2, y2, z2, x + 0.5, y, z);
    SetPlayerCheckpoint(playerid, x2, y2, z2, 0.5);
Where 'veh' is the ID of the vehicle you want to set the checkpoint on.

EDIT:
Example of what this would look like, with the '0.5' offset.



Reply


Messages In This Thread
wheel Trigometry - by Pillhead2007 - 01.08.2014, 17:57
Re: wheel Trigometry - by Threshold - 02.08.2014, 00:19
Re: wheel Trigometry - by Threshold - 02.08.2014, 06:25
Re: wheel Trigometry - by Pillhead2007 - 02.08.2014, 09:19

Forum Jump:


Users browsing this thread: 1 Guest(s)