Jump to content
Sign in to follow this  
natanbrody

ArmA 3 Beta Editor - Help - Getting Enemy Units To Follow A Player

Recommended Posts

Could someone explain to me a way to get an enemy squad to follow the players unit as if they were an elite tracker team.

Thanks in advance!!

Share this post


Link to post
Share on other sites

Loop a getPos player and move the enemy's waypoint there or just tell the Ai to go to that spot.

Share this post


Link to post
Share on other sites
This but instead of moving a marker you move a waypoint. :) Super busy today, but if you don't figure it out soon I'll put more code up in a bit.

Share this post


Link to post
Share on other sites

Here a little code to get you going, may need a little editing depending on where you want to implement this. e,g in unit init box or from a trigger or script etc

trackerGroup = group trackerLeader;
trackerCurrentWP = currentWaypoint trackerGroup;
if (trackerCurrentWP == count waypoints trackerGroup) then {
trackerGroup addWaypoint [(getPosATL player), 2, trackerCurrentWP];
};
handle = [trackerGroup, trackerCurrentWP] spawn {
while {alive player} do {
	_this setWaypointPosition [(getPosATL player),2];
	sleep 10;
};
};

Commented code

//get the group from the name of one of the units (trackerleader)
//replace trackerleader with this if putting code in a units init box
trackerGroup = group trackerLeader;
//get current waypoint index
trackerCurrentWP = currentWaypoint trackerGroup;
//if current == total number of waypoints
//then all waypoints have been completed
if (trackerCurrentWP == count waypoints trackerGroup) then {
//add a new waypoint
trackerGroup addWaypoint [(getPosATL player), 2, trackerCurrentWP];
//add other commands here to set waypoint cobat mode etc
};
//create a new thread, pass in current waypoint
handle = [trackerGroup, trackerCurrentWP] spawn {
while {alive player} do {
	//update waypoint position to players position every 10 seconds
	_this setWaypointPosition [(getPosATL player),2];
	sleep 10;
};
};

test mission

Stepping into the trigger will either:-

change their current waypoint to the players position every 10 seconds

or

if the group have finished their waypoints, will add a new waypoint to track the player every 10 seconds

Edited by Larrow
  • Like 1

Share this post


Link to post
Share on other sites

Something easy : put "guard" WP for the ofpor groups and reveal them where the player is by writing this in each of their leader init line :

group this reveal player

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  

×