I also did this function which might suit you better for this application. This one also works relative to the reference object's direction. This one requires x, y, z offset parameters instead of angle and distance parameters. Here it is:
/*---------------------------------------------------------------
SetObjPosObj function by Raptorsaurus
This function sets an object relative to another object but offset from that object
according to user defined parameters. It will also return the new position.
The required info passed to this function is:
Reference object name
The object to be placed name
Front/Back offset (positive to have object placed in front, negative to place behind)
Left/Right offset (positive to have object placed to right, negative to place to left)
above/below offset (positive to have object placed above, negative to to place below)
Example:
_refobj = _car
_plcobj = _aaguy
_offFB = -2
_offLR = -10
_offAB = 5
_pos = [_refobj,_plcobj,_offFB,_offLR,_offAB] call SetObjPosObj
This will put the _aaguy 2 meters behind the _car, 10 meters to the left of the _car
and 5 meters above the _car. The _pos will be an x,y,z array for the _aaguy's position.
Initialize this function by putting this in your init.sqs:
SetObjPosObj = preprocessFile "SetObjPosObj.sqf"
---------------------------------------------------------------*/
// declare private variables
private ["_Refpos","_x","_y","_z","_Refdir","_offFB","_offLR","_offAB","_leadX","_leadY"];
private ["_leewX","_leewY","_pos","_refobj","_plcobj"];
_refobj = _this select 0;
_plcobj = _this select 1;
_offFB = _this select 2;
_offLR = _this select 3;
_offAB = _this select 4;
_Refdir = getDir _refobj;
_Refpos = getPos _refobj;
_x = _Refpos select 0;
_y = _Refpos select 1;
_z = (_Refpos select 2) + _offAB;
// Setup _plcobj position relative to _refobj
_leadX = (_offFB * Sin _Refdir);
_leadY = (_offFB * Cos _Refdir);
_leewX = (_offLR * Sin (_Refdir + 90));
_leewY = (_offLR * Cos (_Refdir + 90));
_pos = [(_leadX + _leewX + _x),(_leadY + _leewY + _y),_z];
_pos