Retrieving object position while attached to a car
#1

I'm making a vehicle attachments system and when an object is attached to a vehicle and the player tries to edit it, it won't let him. So i'm trying to recreate the object everytime a player wants to adjust the position of it. However, I have no idea how to get the object's position. GetObjectPos wouldn't work normally because the object is attached.
Reply
#2

If you are trying to get the attached position you need to offset it from the vehicle's coordinates.

pawn Код:
stock GetAttachedObjectPos(objectid, vehicleid, &Float: x, &Float: y, &Float: z)
{
    if(IsValidObject(objectid) && GetVehicleModel(vehicleid))
    {
            new Float: pos[3], Float: vpos[3];
            GetObjectPos(objectid, pos[0], pos[1], pos[2]);
            GetVehiclePos(vehicleid, vpos[0], vpos[1], vpos[2]);

            x = vpos[0]-pos[0];
            y = vpos[1]-pos[1];
            z = vpos[2]-pos[2];
            return 1;
    }

    else return 0;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)