Jump to content
gitrinec

[SOLVED] Place units in a 360 degree circle position facing inward toward an object

Recommended Posts

I think I used to have a script back in ofp resistance may be that I used to place units in a 360 degree circle, but I've not done any Arma3 scripting.  Is it possible to place units in a 360 degree circle facing inward at a specific object within a specific distance?

 

Edited by gitrinec
Solved the question
  • Like 1

Share this post


Link to post
Share on other sites

99b8a2ba71ce2c2eeb933d07c63698e07323d1e9Well I'm a bit stuck on this, I've got them in a 180 but they seem stuck in a Z axis sort of 360. I've also notice they won't move after they get rendered.  I found some code on the forums  from Hallyg and have changed it a bit , just working out plane translation or something.

 

_radius = 2;
_playerpos = getPos player;
hint str _playerpos;
_origin = ( getPosASL testobj) vectorAdd [0,0,-10];
//_origin = getPos testobj;
//_origin = getPosASLW testobj;
//_grp = createGroup west;
//hint str side _grp;
//hint str _origin;
for "_i" from 1 to 10 do {
//systemChat str _i;
 _unit  = group player createUnit [ "B_SL_Frogman_Team_Leader_01",_origin, [], 0, "FORM" ];
 _unit enableSimulationGlobal false;
 removeBackpack _unit;
  removeAllWeapons _unit;
  _unit setBehaviour "SAFE";
   // _veh enableSimulation false;

 _theta = ((2 * pi * _i)/300) * (180/pi);
  // _theta = 36 * _i;
   // _phi = acos((2 * (random 1)) - 1);
_phi = Random 180;
    _x = _radius * sin(_phi) * cos(_theta);
	//hint str _x;
    _y = _radius * sin(_phi) * sin(_theta);
	//hint str _y;
    _z = _radius * cos(_phi);
	
	//_z = 0;
	//systemChat str _z;
 //_unit  = group player createUnit [ "B_Soldier_F", _origin, [], 0, "FORM" ];
 
   _unit setPosASL (_origin vectorAdd [_x, _y, _z]);
 // systemChat str getPosASL _unit;
  _gridPos = mapGridPosition  getPosASL _unit;
//systemChat str _gridPos;
};

 

Edited by gitrinec
Added image

Share this post


Link to post
Share on other sites

Merry Christmas GEORGE FLOROS GR.

 

I've downloaded a bunch of your scripts lately, been working with your winter environment script, was able to get the snow to stop going through the ocean out to sea.  Thanks for the link, I'm thinking it has something to do with the addvector 3d space as you can see in the image they stack vertically and not around the SDV.  I'll take a look at that script later today that you linked too.

 

Thanks

  • Thanks 1

Share this post


Link to post
Share on other sites
10 hours ago, GEORGE FLOROS GR said:

Hello there gitrinec and merry christmas !

 

Have you checked this ?

 

I made some tweaks to that script and it works great. I'll prob have to tweak it some more for underwater.

a51a01d73ae12da9c4692b03c6e0e441e568174e

Thanks again.

  • Like 1

Share this post


Link to post
Share on other sites
2 minutes ago, gitrinec said:

Thanks again.

 

Nice !

But once you have the solution , it will be good also to share it !

Share this post


Link to post
Share on other sites

Select units. Apply this code:
 

Spoiler

 


private _centre = screenToWorld [0.5, 0.5];
private _radius = screenToWorld [0.5, 0.5] distance2D screenToWorld [1, 0.5];
private _selected = get3DENSelected "object";

if (count _selected == 0) exitWith { };

private _angleIncrement = 360 / count _selected;
private _angle = 0;

collect3DENHistory {
    {
        _x set3DENAttribute ["position", 
            _centre vectorAdd [_radius * -(sin _angle), _radius * -(cos _angle), 0]];

        _x set3DENAttribute ["rotation", [0, 0, _angle]];

        _angle = _angle + _angleIncrement;
    }
    forEach _selected;

    do3DENAction "LevelWithSurface";
};

 

 

 


All credits to @foxhound
https://foxhound.international/arma-3-eden-scripting.html

  • Like 1

Share this post


Link to post
Share on other sites
31 minutes ago, GEORGE FLOROS GR said:

 

Nice !

But once you have the solution , it will be good also to share it !

Here is what I used with some tweaks to make sure the units face the obj they were around and made the AI disabled for a brief amount of time so that they stay in the desired position.  The numbers passed to the params can be changed to suit one's needs. That gave me 4 units facing the object.

[2, 3] params ["_radius","_width"];

_pos = getPos sdv1; 
_pos params ["_px","_py" ]; 

_index = 0;

_circ = floor ((2 * pi) * _radius);
_radials = floor (_circ / _width);
_factor = (360 / _radials);
systemChat str _radials;
for "_i" from 0 to (_radials - 1) do 

{ 
    _ix = (_i * _factor); 
    _yaw = (180 - _ix); // yaw-pitch-roll need to be adjusted depending on object and orientation
    _roll = 0; 
    _pitch = 0; 
   
    _dirx = sin(_yaw) * cos(_roll); 
    _diry = cos(_yaw) * cos(_roll); 
    _dirz = sin(_roll); 
    _upx = cos(_yaw) * cos(_roll) * sin(_pitch); 
    _upy = sin(_yaw) * cos(_roll) * sin(_pitch); 
    _upz = cos(_roll) * cos(_pitch); 
    
    _ox = (_radius * cos _ix); 
    _oy = (_radius * sin _ix); 
    
    _obj = group player createUnit ["B_SL_Frogman_Team_Leader_01",[0,0,0],[],0,"FORM"]; 
    
    _obj setVectorDirAndUp [[_dirx,_diry,_dirz],[_upx,_upy,_upz]]; 
    _obj setPosATL [_px + _ox, _py + _oy, -0.2];
    _obj setBehaviour "SAFE";
    _rotation = [_obj, _pos] call BIS_fnc_relativeDirTo;
    _obj setDir (getDir _obj) +_rotation;
    _obj lookAt _pos;
    doStop _obj;
    _obj disableAI "move";
    sleep 0.5;
    _obj enableAI "move";
    _index = _index +1;
};

 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
21 hours ago, gitrinec said:

Thanks Gunter Severloh I'll check it out.

I was reminiscing in my post, that mod wont work in Arma3 although i haven't tried it, but its for arma2oa, i just happen to see your post and it brought up memories when i had

that mod in my COWarMod back in the day for arma2oa, and the Author whom i miss was a regular vet on the forums here for the longest time, no longer around

at least not visiting I miss alot of these guys.

    But try it, if it works let me know, cheers!

Share this post


Link to post
Share on other sites
On 12/26/2019 at 5:09 PM, gitrinec said:

Here is what I used

 

Looks familiar 🙂
Glad you got it sorted!

  • Like 1

Share this post


Link to post
Share on other sites
45 minutes ago, Harzach said:

 

Looks familiar 🙂
Glad you got it sorted!

Thanks for creating most of the script Harzach!! 

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

×