Strange.. AttachDynamicObjectToVehicle
#1

pawn Код:
public OnPlayerEditDynamicObject(playerid, objectid, response, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz)
{
    if(VehicleModification[playerid] == 1)
    {
        if(response == EDIT_RESPONSE_FINAL)
        {
            if(CreatingMod[playerid] != -1)
            {
                new m = CreatingMod[playerid];
                new v = EditingVehicle[playerid];

                ModInfo[m][mVW] = GetPlayerVirtualWorld(playerid);
                ModInfo[m][mINT] = GetPlayerInterior(playerid);
                ModInfo[m][mX] = x;
                ModInfo[m][mY] = y;
                ModInfo[m][mZ] = z;
                ModInfo[m][mRX] = rx;
                ModInfo[m][mRY] = ry;
                ModInfo[m][mRZ] = rz;
                ModInfo[m][mCreated] = 1;
                ModInfo[m][mVehicleID] = v;
               
                new Float:X, Float:Y, Float:Z, Float:Face;
                GetVehiclePos(VehicleInfo[v][vVehicle], X, Y, Z);
                GetVehicleZAngle(VehicleInfo[v][vVehicle], Face);

                SendClientMessage(playerid, COLOR_ORANGE, "[INFO]: Vehicle Modifcation Create/Saved");

                DestroyDynamicObject(ModInfo[m][mMod]);
                ModInfo[m][mMod] = AddDynamicObject(ModInfo[m][mModel], ModInfo[m][mX], ModInfo[m][mY], ModInfo[m][mZ], ModInfo[m][mRX], ModInfo[m][mRY], ModInfo[m][mRZ], ModInfo[m][mVW], ModInfo[m][mINT], -1);
               
                VehicleInfo[v][vModifications] += 1;

                printf("BEFORE ATTACHED: x = %f | y = %f | z = %f | rx = %f | ry = %f | rz = %f", x, y, z, rx, ry, rz);

                x = x - X;
                y = y - Y;
                z = z - Z;

                AttachDynamicObjectToVehicle(ModInfo[m][mMod], VehicleInfo[v][vVehicle], x, y, z, ModInfo[m][mRX], ModInfo[m][mRY], ModInfo[m][mRZ]);

                new Float:ox, Float:oy, Float:oz, Float:orx, Float:ory, Float:orz;
                GetDynamicObjectPos(ModInfo[m][mMod], ox, oy, oz);
                GetDynamicObjectRot(ModInfo[m][mMod], orx, ory, orz);
                printf("AFTER ATTACHED: x = %f | y = %f | z = %f | rx = %f | ry = %f | rz = %f", ox, oy, oz, orx, ory, orz);
               
                ModInfo[m][mX] = x;
                ModInfo[m][mY] = y;
                ModInfo[m][mZ] = z;
                ModInfo[m][mRZ] = rz;
               
                CreatingMod[playerid] = -1;
                return 1;
            }
Ok we have the positioning of the object bang on. We're trying to see what's changing in the rotation of the object. When the object is attached it shifts on rotation, however when debugging in the console it's showing every coordinate as if it hasn't moved at all.

Could any one explain why that is?
Reply
#2

Has any one got attaching an object to work perfectly? The ROT of the object in regards to the offset of the vehicle is my problem here. X,Y,Z are placed just fine.

I can only get the Z angle of the vehicle also and can't check the ROT of the object before and after because it stays at 0.0 0.0 0.0 before and after and I know this is incorrect as it moves when attached.
Reply
#3

Any ideas on this please?
Reply
#4

Your vehicle needs to be facing due north rotation (0.0, 0.0, 0.0) for this to work correctly when making edits.
Reply
#5

You can only set the Z angle for a vehicle though? I've set the vehicle to be 0.0 on everything before doing this.
Reply
#6

Yes, you need to make sure this is done only on flat ground simply keep setting the vehicle z angle to 0.0 in OnPlayerEditDynamicObject() when the event type is 'EDIT_RESPONSE_UPDATE'.

Please refer to Texture Studio to see how this works.
https://github.com/Pottus/Texture-St...o/vehicles.pwn
Line: 1271

Key features to ensure this works.

1.) A pivot object is used (1974) the golf ball is textured solid yellow.
2.) The pivot objects position is translated to offsets.
3.) The object is re-attached every update so what you see is what you get! You cannot move an object and expect that the position it is in will be the same without a real time update of that objects attached position.
Reply
#7

Quote:
Originally Posted by Pottus
Посмотреть сообщение
Yes, you need to make sure this is done only on flat ground simply keep setting the vehicle z angle to 0.0 in OnPlayerEditDynamicObject() when the event type is 'EDIT_RESPONSE_UPDATE'.

Please refer to Texture Studio to see how this works.
https://github.com/Pottus/Texture-St...o/vehicles.pwn
Line: 1271

Key features to ensure this works.

1.) A pivot object is used (1974) the golf ball is textured solid yellow.
2.) The pivot objects position is translated to offsets.
3.) The object is re-attached every update so what you see is what you get! You cannot move an object and expect that the position it is in will be the same without a real time update of that objects attached position.
Interesting thank you very much I'll look further into this. The amount of different formulas I have tried and scratched my head at why it isn't working is un real. Kind of silly how there is a function specifically for "OnPlayerEditAttachedObject" yet none for vehicle objects that are being attached. Seems like such a huge cow boy job just because there isn't yet something for it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)