18.05.2011, 23:57
ok so here is the , attachobject, note rz is at 95.0
so, i want this object to face a point. AKA - the point in this situation is another vehicle's pos.
so
everything works fine, but , sometimes, the angle is just pure wrong, for about 0 - 150 it kinda works nice. but otherwise, its just plain wrong or goes weird.
ok well, Angle2D seems to always be returning the correct angle, but you know that for attachobjecttovehicle you need a small offsets, thats 95.0, if you dont put 95.0+angle it wont even work at all because at 95.0 its actually looks like its at 0.0
pawn Код:
AttachObjectToVehicle(Vehicle_Machine_Special_Object[id], id, 0.1, -0.5, 1.5, 0.0, 30.0, 95.0);
so
pawn Код:
new Float:x, Float:y, Float:z, Float:x2, Float:y2, Float:Angle, closestvehicle = GetClosestVehicle(playerid, 25.0);
GetVehiclePos(vehicleid, x, y, z);
GetVehiclePos(closestvehicle, x2, y2, z);
Angle = Angle2D(x, y, x2, y2);
SendClientMessageFormatted(playerid, -1, "[System] - playerid: %d - closestvehicleid: %d - Angle2D: %f - Angle2D + 95: %f", playerid, closestvehicle, Angle, 95.0 + Angle);
AttachObjectToVehicle(Vehicle_Machine_Special_Object[vehicleid], vehicleid, 0.1, -0.5, 1.5, 0.0, 30.0, 95.0 + Angle);
stock Float:Angle2D(Float:PointAx, Float:PointAy, Float:PointBx, Float:PointBy)
{
new Float:Angle;
Angle = atan2(PointAy < PointBy ? PointBy - PointAy : PointAy - PointBy, PointAx < PointBx ? PointBx - PointAx : PointAx - PointBx);
Angle = PointAx < PointBx ? 270.0 + Angle : 90.0 - Angle;
Angle = PointAy < PointBy ? Angle : 180.0 - Angle;
return Angle < 0.0 ? Angle + 360.0 : Angle;
}
ok well, Angle2D seems to always be returning the correct angle, but you know that for attachobjecttovehicle you need a small offsets, thats 95.0, if you dont put 95.0+angle it wont even work at all because at 95.0 its actually looks like its at 0.0