Johan Even Posted September 22, 2009 Share Posted September 22, 2009 Dear All, Recently I have been working on a nice idea to be able to haul cars using a Packer, so that one would park a sedan or similar vehicle straight on the Packer's ramp, and this vehicle would not move while the Packer is on the move. The problem, as far as I understand, is that attachElementToElement requires offset values for rotation parameters, while in this case it would have been easier to get the vehicle's rotation and position and simply use them for attaching. The best variant I have developed is as follows: function fastenVehicle (thePlayer, command) -- the handler for the /fasten command -- the function gets the vehicle that will be fastened to the carrier and stores it in the fastened_veh variable fastened_veh=getPedOccupiedVehicle(thePlayer) if (fastened_veh ~= false) then setVehicleEngineState(fastened_veh, false) outputChatBox("Vehicle Ready for Transportation", thePlayer) end end function startHaul (thePlayer, command) -- the handler for the /starthaul command -- should attach the vehicle that is going to be hauled to the Porter main_veh=getPedOccupiedVehicle(thePlayer) local mx, my, mz = getElementPosition (main_veh) local fx, fy, fz = getElementPosition (fastened_veh) local mrx, mry, mrz = getVehicleRotation (main_veh) local frx, fry, frz = getVehicleRotation (fastened_veh) local ox, oy, oz, orx, ory, orz ox = mx-fx oy = my-fy oz = fz-mz orx = mrx-frx ory = mry-fry orz = 0 if getElementModel (main_veh) =443 then result = attachElements(fastened_veh, main_veh, ox,oy,oz,frx,0,0) if (result == false) then outputChatBox("Failed to start haul", thePlayer) else outputChatBox("Haul started", thePlayer) end end end The problems are as follows: The attached position differs from the position where vehicle is left. E.g. can be left near the top of the ramp, or right at the bottom. Looks like the math should be improved, but how? When the elements are attached, the vehicle's position is shifted (e.g. the wheels show below the ramp) After 1 or two seconds the camera shifts to the vehicle at the ramp, and keeps doing so everytime you enter the Packer. The view differs from that when nothing is attached I have tried to attach a vehicle on top (for learning purposes), when it is at a vertical distance, the Packer moves like a charm and there's no camera shift. So... my question really is whether it is possible to do the trick without complex trigonometry mentioned elsewhere in this forum and what math should be improved to keep the vehicle in position when attaching and also keep camera on the main vehicle, not on the attached one. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now