stock SetObjectFaceCoords3D(iObject, Float: fX, Float: fY, Float: fZ, Float: fRollOffset = 0.0, Float: fPitchOffset = 0.0, Float: fYawOffset = 0.0) {
new
Float: fOX,
Float: fOY,
Float: fOZ,
Float: fPitch
;
GetObjectPos(iObject, fOX, fOY, fOZ);
fPitch = floatsqroot(floatpower(fX - fOX, 2.0) + floatpower(fY - fOY, 2.0));
fPitch = floatabs(atan2(fPitch, fZ - fOZ));
fZ = atan2(fY - fOY, fX - fOX) - 90.0; // Yaw
SetObjectRot(iObject, fRollOffset, fPitch + fPitchOffset, fZ + fYawOffset);
}
Használat:
iArrowObject = CreateObject(1318, 0.0, 0.0, 3.0, 0.0, 0.0, 0.0);
public OnPlayerUpdate(playerid) {
new
Float: fX,
Float: fY,
Float: fZ
;
GetPlayerPos(playerid, fX, fY, fZ);
SetObjectFaceCoords3D(iArrowObject, fX, fY, fZ, 0.0, 180.0, 90.0);
return 1;
}