The following functions do exactly what you want: place an object exactly at the relative position [x,y,z], according to the target's direction. It works just like the setCamRelPos, yet you don't need a camera. Therefore, regardless of the target's height, the object will be always placed at the defined relative position.
;ECP v1.075 UPDATED FUNCTIONS
;ECP_resources index 32
ECP_getGloPos = {private ["_hgtRef","_altRef","_alt","_ref","_relpos","_ang","_dis","_glopos"]; _ref = _this select 0; _relpos = _this select 1; _altRef = _this select 2; _hgtRef = _this select 3; _ang = getdir _ref + ([[[0,0],_relpos] call ECP_getDirPos); _dis = SQRT(((_relpos select 0)^2)+((_relpos select 1)^2)); _altRef setPos [position _ref select 0,position _ref select 1,0]; _alt = _altRef distance _ref; _glopos = [(position _ref select 0)+_dis*(sin _ang),(position _ref select 1)+_dis*(cos _ang)]; _altRef setPos _glopos + [0]; _hgtRef setPos _glopos; _alt = _alt - (_altRef distance _hgtRef); _glopos + [_alt+(_relpos select 2)+0.381]}
;ECP_resources index 33
ECP_getRelPos = {private ["_hgtRef","_altRef","_alt","_ang","_dis","_ref"]; _ref = _this select 0; _altRef = _this select 2; _hgtRef = _this select 3; _ang = ([position _ref,_this select 1] call ECP_getDirPos) - getDir _ref; _dis = [_this select 1,position _ref] call ECP_distancePos; _altRef setPos [(_this select 1) select 0,(_this select 1) select 1,0]; _hgtRef setPos (_this select 1); _alt = _altRef distance _hgtRef; _altRef setPos [position _ref select 0,position _ref select 1,0]; [_dis*(sin _ang),_dis*(cos _ang), _alt - (_altRef distance _ref) - 0.381]}
The syntax and arguments are:
object setPos ([<target>,<relative position>,<altitude (sea level) reference>,<height reference>] call ECP_getGloPos)
relativePosition = ([<target>,<object's global position>,<altitude (sea level) reference>,<height reference>] call ECP_getRelPos)
The sea level reference and height reference should be, respectively:
_altRef = "emptydetector" createVehicle _
_hgtRef = "logic" createVehicle _
I hope it helps you out.
#EDIT!!!
Doh! Just realised that there are two other funcs that are being used by those two. They are:
//3 - Modified 10/02/04 by MorMel (Komuna) -> "Zero Divisor" error avoided, for MMK functions compatibility
ECP_getDirPos = {private["_from","_to","_y","_return"]; _from = _this select 0; _to = _this select 1; _y = ((_to select 1) - (_from select 1)); _return = ((_to select 0) - (_from select 0)) atan2 (IF (_y==0) THEN {1e-10} ELSE {_y}); if ( _return < 0 ) then { _return = _return + 360 }; _return}
//8
ECP_distancePos = {sqrt( (((_this select 0) select 0)-((_this select 1) select 0))^2 + (((_this select 0) select 1)-((_this select 1) select 1))^2 )}