Jump to content
beeper

How to find top of model margins

Recommended Posts

I want to attach "CBA_B_InvisibleTargetVehicle" to my empty vehicles, so enemy will attack these vehicles, but I need to find offset for "attachTo" command arguments, any help? If I set zero offset

attachTo [_this, [0, 0, 0]];

then invisible target hides in vehicle hull (enemy don't react, don't see target), so only I can is put target on top of it. Is it possible to find correct offset, so target will be visible to enemy AI but not so far so AI will hit target vehicle.
Thanks!

Share this post


Link to post
Share on other sites

maybe this could work for your situation (objA should be on ground during execution):

_obj = objA; 
_obj_to_attach = objB; 
  
_pos_obj = position _obj; 
 
_bbr = boundingBoxReal _obj; 
_p1 = _bbr select 0; 
_p2 = _bbr select 1;
_maxHeight = abs ((_p2 select 2) - (_p1 select 2)); 
 
_pos_obj set [2, _maxHeight];

_attach_pos = _obj worldToModel _pos_obj;

_obj_to_attach attachTo [_obj, _attach_pos];

objA - the object which gets an attachment (objB)

objB - the object which gets attached to objA

  • Like 1

Share this post


Link to post
Share on other sites

I have Integrated this code with this result (too high), any ideas?
target.jpg

Share this post


Link to post
Share on other sites

the script uses boundingBoxReal to find the highest point of the object. In your screenshot this is the top of the highest antenna.

it is possible to detect a lower point beside the antenna with lineIntersectsSurfaces but this is an effort which Im not recommending if not really needed.

 

Better way would be to do a manual solution for this specific object type like:

 

_obj = objA; 
_obj_to_attach = objB; 

_height_correction =
[
  [ "tank1_classname", -2 ],
  [ "car12_classname", -1.5 ],
  [ "towerA_classname", -4.37 ]
];

_pos_obj = position _obj; 
 
_bbr = boundingBoxReal _obj; 
_p1 = _bbr select 0; 
_p2 = _bbr select 1;
_maxHeight = abs ((_p2 select 2) - (_p1 select 2));

_index = _height_correction findIf { typeOf _obj == (_x select 0) };

if not ( _index < 0) then
{
 _maxHeight = _maxHeight + (_height_correction select _index select 1);
};

_pos_obj set [2, _maxHeight];

_attach_pos = _obj worldToModel _pos_obj;

_obj_to_attach attachTo [_obj, _attach_pos];

 

  • Like 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×