Maths :( (Vehicle tire offset) - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Maths :( (Vehicle tire offset) (
/showthread.php?tid=411705)
-fixed- -
MP2 - 30.01.2013
Trying to get the coordinates of all 4 tires on a vehicle..
pawn Code:
// Find the tirepos and creates an object there to see if it's right (it is)
new vehicleid = GetPlayerVehicleID(playerid);
new model = GetVehicleModel(vehicleid);
// Get vehicle position
new Float:x, Float:y, Float:z;
GetVehiclePos(vehicleid, x, y, z);
// Get vehicle angle
new Float:vehAngle;
GetVehicleZAngle(vehicleid, vehAngle);
// Get Offsets
new Float:wheelOffset[3];
GetVehicleModelInfo(model, VEHICLE_MODEL_INFO_WHEELSFRONT, wheelOffset[0], wheelOffset[1], wheelOffset[2]);
wheelOffset[0] += 0.7; // Bit further out on x axis, so it's not actually INSIDE the wheel (the object)
// This gets the FRONT RIGHT wheel. Find out how to get others
x += (floatcos(vehAngle, degrees) * wheelOffset[0]) - (floatsin(vehAngle, degrees) * wheelOffset[1]);
y += (floatsin(vehAngle, degrees) * wheelOffset[0]) + (floatcos(vehAngle, degrees) * wheelOffset[1]);
CreateDynamicObject(1238, x, y, z, 0, 0, 0);
That gets the FRONT LEFT one, but how about the others? I've tried countless things :/
I need to use VEHICLE_MODEL_INFO_WHEELSBACK to get the back ones, but firstly I need the front left one. I've tried 'reversing' the offset (if the offset is 0.7, change it to -0.7) but that doesn't work..
Any help appreciated, thanks.
Re: Maths :( (Vehicle tire offset) -
ikey07 - 30.01.2013
what does VEHICLE_MODEL_INFO_WHEELSFRONT gets?
If it gets center between front wheels you can use VEHICLE_MODEL_INFO_SIZE to get side offset, but if it gets one side, then just one side is X and other side is X = X-(X*2)
Re: Maths :( (Vehicle tire offset) -
MP2 - 30.01.2013
I appear to have fixed it. I had to use temporary x and y variables, as if they are changed for the front right wheel, they will no longer be offset from the center of the vehicle, but from the front right wheel.
Result:
www.puu.sh/1UOPY
Re: Maths :( (Vehicle tire offset) -
ScIrUsna - 09.04.2016
Maybe could post code?