10.09.2018, 02:34
You could use the ZAngle but that will only work on flat ground, to do that accurate you need to use GetVehicleRotationQuat
Combine one of these with GetVehicleModelInfo to get behind (+ your offset) of the vehicle
For the ZAngle you could reuse this function
For the quat solution search for an include
Combine one of these with GetVehicleModelInfo to get behind (+ your offset) of the vehicle
For the ZAngle you could reuse this function
PHP код:
GetInFrontOfAngle(Float: angle, &Float:x, &Float:y, Float:distance) {
x -= distance * floatsin(angle, degrees);
y += distance * floatcos(angle, degrees);
}
PHP код:
new Float: x, Float: y, Float: z, Float: a;
GetVehiclePos(vehicleid, x, y, z);
GetVehicleZAngle(vehicleid, a); // a is facing to the front
// a + 180 = behind | a - 90 = right | a + 90 = left
GetInFrontOfAngle(a + 180.0, x, y, 5.0); // 5.0 behind vehicle center
GetInFrontOfAngle(a - 90.0, x, y, 3.0); // 5.0 behind, 3.0 to the right
// save current position in new variables
new Float: firstX = x, Float: firstY = y;
GetInFrontOfAngle(a + 90.0, x, y, 7.0); // 5.0 behind, 4.0 (3.0 - 7.0) to the left
new Float: secondX = x, Float: secondY = y;
// and so on