MoveObject After AttachObjectToVehicle
#1

I was just wondering can an object be moved if it has been attached to a vehicle? I have some code that attaches SAM sites to a truck, and when vehicle horn is pressed two hydra flares are attached to the SAMs and then moved towards a player that is in an air vehicle. I would just "GetObjectPos" on the SAMs and just create the object there and move them but "GetObjectPos" seems to be very inaccurate, so wont work. (spawning the flares way behind the truck).

Heres a snippet
pawn Код:
if(!gAATData[iTruckIdx][e_bMissileFired_1])
    {
        new
            iTargetVehicleid,
            Float:fpX, Float:fpY, Float:fpZ;
           
        GetPlayerPos(gAATData[iTruckIdx][e_iDriverID], fpX, fpY, fpZ);
       
        foreach(Player, playerid)
        {
            iTargetVehicleid = GetPlayerVehicleID(playerid);
           
            if((IsAnAirplane(iTargetVehicleid) || IsAHelicopter(iTargetVehicleid)) && IsPlayerInRangeOfPoint(playerid, MISSILE_TARGET_RANGE, fpX, fpY, fpZ))
            {
                gAATData[iTruckIdx][e_iMissileID_1] = CreateObject(354, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 200);
                AttachObjectToVehicle(gAATData[iTruckIdx][e_iMissileID_1], gAATData[iTruckIdx][e_iAatVehicleid], 0.01, -3.85, -0.80, 0.00, 0.00, 0.00);
                GetPlayerPos(playerid, fpX, fpY, fpZ);
                //move object
                MoveObject(gAATData[iTruckIdx][e_iMissileID_1], fpX, fpY, fpZ, MISSILE_SPEED);//not moving
                gAATData[iTruckIdx][e_iMissileTimer_1] = SetTimerEx("SVEH_MissileUpdate", 1000, true, "iii", playerid, gAATData[iTruckIdx][e_iMissileID_1], iTruckIdx);
               
                gAATData[iTruckIdx][e_iMTimerActive_1] = true;
                gAATData[iTruckIdx][e_bMissileFired_1] = true;
                return;
            }
       
        }
    }
If someone has a half decent workaround please let me know.
Reply
#2

You can not move objects attached to anything.
If you for eg. attach object A to object B, you can't move object A itself but you can move object B and A will follow.
Reply
#3

Ok thanks. A way to de-attach would be nice

I had an idea anyway, can't believe i never thought of it sooner. I can just use the offsets of the SAMs, on the current vehicle co-ords and just CreateObject/move.

Thanks for the reply.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)