Attaching other vehicles to the packer truck
#8

Tried it and it works, kinda.
But it's still un-realistic.
The Elegy floats above the packer and your camera is blocked by it when driving the Packer.
Lowering the Elegy until it touches the packer causes bad driving behaviour of the Packer and such abnormalities.
The Elegy was put in place each time OnPlayerUpdate was executed (30 times per second).
This pushed against the Packer and you couldn't drive the Packer properly anymore.

But the Elegy nicely followed the Packer, except when the packer was wiggling left and right because of non-flat terrain.
Also, driving on a ramp didn't cause the Elegy to tilt.

This was my test-code:
pawn Код:
new Elegy, Packer;

// This callback is called very frequently per second (about 30 times per second)
public OnPlayerUpdate(playerid)
{
    new Float:x, Float:y, Float:z, Float:rot;

    // Check if the player is inside the packer
    if (GetPlayerVehicleID(playerid) == Packer)
    {
        GetVehiclePos(Packer, x, y, z);
        GetVehicleZAngle(Packer, rot);

        SetVehiclePos(Elegy, x, y, z + 2.5);
        SetVehicleZAngle(Elegy, rot);
    }

    return 1;
}

// This callback gets called when the server initializes the filterscript
public OnFilterScriptInit()
{
    Elegy = CreateVehicle(562, 0.0, 0.0, 5.0, 0.0, 0, 0, 300);
    Packer = CreateVehicle(443, 10.0, 0.0, 5.0, 0.0, 0, 0, 300);

    return 1;
}
Maybe some of this could be used for the Leviatan helicopter to transport vehicles that way.
Perhaps using a fast timer instead of OnPlayerUpdate, as this could lag the server when there are 100 players online.

It doesn't have to be a real vehicle that you can drive.
It would be used as a new job-type for truckers, who could transport vehicles from one location to another.
The spawned vehicle doesn't really need to drive at all. It's only use would be aestethical, to make it seem the Packer is transporting a real vehicle.

But I still can't spawn a vehicle as an object, which would be the best.
Then it would really move together with the Packer.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)