Jump to content
Sign in to follow this  
smallhill

Can I make an AFV follow a group?

Recommended Posts

Hi,

I want an AFV to follow a group at a set distance, I've tried the doFollow command but can't seem to make it work. There's probably more to it.

Share this post


Link to post
Share on other sites
//eg vehicle init field
//nul = [this,groupNameToFollow] execVM "follow.sqf";
private ["_pos","_cntrPos","_vcl","_grp","_wPArray","_wp1"];

_vcl = _this select 0;
_grp = _this select 1;

//remove all previous waypoints
_wPArray = waypoints (group _vcl);
      for "_i" from 0 to (count _wPArray -1) do 
{
      deleteWaypoint [(group _vcl), _i]
};

//add 1 WP it's all you need
_wp1 = (group _vcl) addWaypoint [getPosATL _vcl, 100];
   _wp1 setWaypointType "MOVE";

//movement loop
while {alive _vcl} do {
_cntrPos = getPosATL (leader _grp);//can be anything or any postition

if (format ["%1", _cntrPos] != "[0,0,0]") then {
//follow a position 100m south of the current group leader
   _pos = [(_cntrPos select 0) + (100 * sin(180)), (_cntrPos select 1) + (100 * cos(180)), 0];//100m south of group leader
     _wp1 setWaypointPosition [_pos, 0];
       (group _vcl) setCurrentWaypoint _wp1;};
sleep 30;
};

Edited by Mattar_Tharkari

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  

×