Creating trailer behind a vehicle using GetVehicleRotationQuat
#1

Hello, as in title I need to create trailer right behind a truck and then attach trailer to it. I've run into problems though, because getting the X and Y axis of the player vehicle is only possible via GetVehicleRotationQuat - which is utterly confusing. How can I translate its result to some kind of offset to certain point? My english isn't good enough to understand the wikipedia article (good Lord, the scientific lingo is killing me).

Let's say this is form of the code
pawn Код:
CMD:addTrailer(playerid, params[]) {
    if(!IsPlayerInAnyVehicle(playerid)) return 0;
    new vid = GetPlayerVehicleID(playerid), Float:Quat[4], Float:Offset[3], Float:Pos[3], Float:Rotation;
    GetVehicleRotationQuat(vid, Quat[0], Quat[1], Quat[2], Quat[3]);
    GetVehiclePos(playerid, Pos[0], Pos[1], Pos[2]);
    //Magic happens here
    //Offsets and Rotation are calculated
    new trailer = CreateVehicle(TRAILERID, Pos[0] + Offset[0], Pos[1] + Offset[1], Pos[2] + Offset[2], Rotation, -1, -1, 0);
    AttachTrailerToVehicle(trailer, vid);
    return 1;
}
Other issue are dimensions of the vehicle itself. I need perfect distance from it, so I can attach the trailer at once, without any movement from the player.

I found https://sampforum.blast.hk/showthread.php?tid=368189 this thread, but can't make anything out of it.
Reply


Messages In This Thread
Creating trailer behind a vehicle using GetVehicleRotationQuat - by Misiur - 09.02.2013, 17:56
Re: Creating trailer behind a vehicle using GetVehicleRotationQuat - by MP2 - 09.02.2013, 18:11
Re: Creating trailer behind a vehicle using GetVehicleRotationQuat - by Misiur - 09.02.2013, 18:21

Forum Jump:


Users browsing this thread: 1 Guest(s)