Maths :( (Vehicle tire offset)
#1

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.
Reply
#2

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)
Reply
#3

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
Reply
#4

Maybe could post code?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)