AttachObjectToVehicle teleports object to blueberry -
reckst4r - 23.10.2013
Hi. I'm trying to attach an object to a vehicle, but everytime I do that, the object just gets teleported to Blueberry.
pawn Код:
AttachObjectToVehicle(LoadBox[vehicleid][ForkliftObject], vehicleid, 0, 0.9, -0.2, 0, 0, 0);
Re: AttachObjectToVehicle teleports object to blueberry -
reckst4r - 24.10.2013
bump
Re: AttachObjectToVehicle teleports object to blueberry -
Aliassassin123456 - 24.10.2013
1. the LoadBox[vehicleid][ForkliftObject] must be valid object
2. the position of LoadBox[vehicleid][ForkliftObject] must be: 0.0,0.0,0.0
also see here:
https://sampwiki.blast.hk/wiki/AttachObjectToVehicle
Re: AttachObjectToVehicle teleports object to blueberry -
Konstantinos - 24.10.2013
Quote:
Originally Posted by Aliassassin123456
2. the position of LoadBox[vehicleid][ForkliftObject] must be: 0.0,0.0,0.0
|
Nope. You can change the offset and the rotation of it.
And yes, LoadBox[vehicleid][ForkliftObject] must be valid (create the object and assign the objectid to that).
Re: AttachObjectToVehicle teleports object to blueberry -
reckst4r - 24.10.2013
I've added the missing .0 to the position & rotation, and I've made sure that the forklift object is valid, and yet it doesn't appear.
Re: AttachObjectToVehicle teleports object to blueberry -
Aliassassin123456 - 24.10.2013
Quote:
Originally Posted by Konstantinos
Nope. You can change the offset and the rotation of it.
|
AttachObjectToVehicle never reset the position of object, example if you need to attach object to this offset of vehicle: 1.0,1.0,1.0 if we set offset of Object to 1.0,1.0,1.0 we can't use 1.0,1.0,1.0 in AttachObjectToVehicle if we do it Object doesn't go to your intentional position
Re: AttachObjectToVehicle teleports object to blueberry -
reckst4r - 24.10.2013
The position of the object that is to be attached to the vehicle isn't 1.0,1.0,1.0
Re: AttachObjectToVehicle teleports object to blueberry -
Aliassassin123456 - 24.10.2013
You need to do something like this:
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVING)
{
LoadBox[GetPlayerVehicleID(playerid)][ForkliftObject] = CreateObject(2000, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
AttachObjectToVehicle(LoadBox[GetPlayerVehicleID(playerid)][ForkliftObject], GetPlayerVehicleID(playerid), 0, 0.9, -0.2, 0, 0, 0);
}
return 1;
}
Re: AttachObjectToVehicle teleports object to blueberry -
reckst4r - 24.10.2013
This is the code where it creates the object & attaches it to the vehicle
pawn Код:
LoadBox[vehicleid][ForkliftObject] = CreateObject(964,-1077.59997559,4274.39990234,3.40000010,0.00000000,0.00000000,0.00000000);
AttachObjectToVehicle(LoadBox[vehicleid][ForkliftObject], vehicleid, 0.0, 0.9, -0.2, 0.0, 0.0, 0.0);
It's under a command, so it doesn't really fit under OnPlayerStateChange in this case :P
Re: AttachObjectToVehicle teleports object to blueberry -
Aliassassin123456 - 24.10.2013
i told you use 0.0,0.0,0.0 for offset of CreateObject !
Try this:
pawn Код:
LoadBox[vehicleid][ForkliftObject] = CreateObject(964,0.0, 0.0, 0.0, 0.00000000, 0.00000000, 0.00000000);
AttachObjectToVehicle(LoadBox[vehicleid][ForkliftObject], vehicleid, 0.0, 0.9, -0.2, 0.0, 0.0, 0.0);