Jump to content
Sign in to follow this  
KingoftheSandbox

Need help with setPos for group

Recommended Posts

What i want to do, is setting a group of players which are in one squad (squadalpha=group this) to a specific position inside one of the industrial sheds and play a animation.

I have to use {_x setpos getPos Name} foreach units alphasquad, because its Multiplayer and its possible that only less players in the squad play. Because of that i cant use variable for every single unit in the squad.

Is there a way setting every single unit of the squad into the shed, using _X code without having them spawn on one point and having them stuck together? A code where i use _x and every single playerunit of the squad spawns on a defined position would be perfect.

Share this post


Link to post
Share on other sites
_leader = leader alphaSquad;
_pos = myPositionToMoveTo;
{
if ( _x != _leader ) then {
	_relDis = _x distance _leader;
	_relDir = [_leader, _x] call BIS_fnc_relativeDirTo;
	_x setPos ([_pos, _relDis, _relDir] call BIS_fnc_relPos);
}; 
}forEach units alphaSquad;
_leader setPos _pos;

This will move the whole of alphaSquad to a new position keeping them all in the same positions relative to the leader. (untested, quickly posting before i leave the house, but ive shown this similar code a couple of times in this forum). Let me know how you get on and ill check it when i get back in a couple of hours.

  • Thanks 1

Share this post


Link to post
Share on other sites

Allready works much better then my code before, but somehow only 7 units getting to the position. So can i change the _relDIS and _relDir so that they are closer to each other? Thanks allready very much! Im off for 1-2 hours but appreciate more feedback from you very much!

I tested the code again, only the leader is not getting ported to the position, can you fix it;-)?

Edited by KingoftheSandbox

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
Sign in to follow this  

×