Jump to content
Sign in to follow this  
thedarkbird

addWayPoint in a for-loop

Recommended Posts

EDIT: Nevermind, I just found out my stupid mistake. Function is ok, I just feeded it units instead of groups.

I'm having this function to move enemy groups to the player position when an alarm is raised. It works like: [group1, group2, group3] execVM "movetoplayer.sqf"

The problem is it only sets a waypoint for the first group in the array, not the others. All groups are identical (apart from their name). After spending hours on it, I really can't find it. Ideas?

//For every group feeded to this function do
for [{_i = 0}, {_i < count _this}, {_i = _i+1}] do
{
//Copy group to _group var
_group = _this select _i;
//Delete group's existing waypoints
while {count waypoints _group > 0} do 
{
	deletewaypoint (waypoints _group select 0);
};
//Add waypoint to player location
_group addWayPoint [position player, 0];
//Set waypoint properties	
[_group, currentWaypoint _group] setWaypointBehaviour "COMBAT";
[_group, currentWaypoint _group] setWaypointSpeed "FULL";
[_group, currentWaypoint _group] setWaypointType "MOVE";	
};

Edited by thedarkbird

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  

×