Jump to content
Sign in to follow this  
hogmason

aircraft waypoints not working

Recommended Posts

ok so i have multiple waypoints being set but the jet goes to its first waypoint then seems to just circle the marker that the waypoint is on for ever. it does not go to its next waypoint

the code.

if (isserver) then
{

 // Set the Navigator
 _Navigator = _this select 0;

    //Navigator Random Marker Selection
    _NavChoices = ["wp1","wp2","wp3","wp4","wp5"] call BIS_fnc_selectRandom;
    _NavMkrs = getmarkerpos _NavChoices;

      //Navigator Waypoints
        _Navwaypoint0 = _Navigator addWaypoint [_NavMkrs, 500];
        _Navwaypoint0 setWaypointType "SAD";
        _Navwaypoint0 setWaypointBehaviour "COMBAT";
        _Navwaypoint0 setwaypointcombatmode "RED"; 
        _Navwaypoint0 setWaypointSpeed "NORMAL";

	 _Navwaypoint1 = _Navigator addWaypoint [_NavMkrs, 500];
        _Navwaypoint1 setWaypointType "SAD";
        _Navwaypoint1 setWaypointBehaviour "COMBAT";
        _Navwaypoint1 setwaypointcombatmode "RED"; 
        _Navwaypoint1 setWaypointSpeed "NORMAL";

	 _Navwaypoint2 = _Navigator addWaypoint [_NavMkrs, 500];
        _Navwaypoint2 setWaypointType "SAD";
        _Navwaypoint3 setWaypointBehaviour "COMBAT";
        _Navwaypoint3 setwaypointcombatmode "RED"; 
        _Navwaypoint3 setWaypointSpeed "NORMAL";

	 _Navwaypoint4 = _Navigator addWaypoint [_NavMkrs, 500];
        _Navwaypoint4 setWaypointType "SAD";
        _Navwaypoint4 setWaypointBehaviour "COMBAT";
        _Navwaypoint4 setwaypointcombatmode "RED"; 
        _Navwaypoint4 setWaypointSpeed "NORMAL";

	 _Navwaypoint5 = _Navigator addWaypoint [_NavMkrs, 500];
        _Navwaypoint5 setWaypointType "CYCLE";
        _Navwaypoint5 setWaypointBehaviour "COMBAT";
        _Navwaypoint5 setwaypointcombatmode "RED"; 
        _Navwaypoint5 setWaypointSpeed "NORMAL";		

};		 


Share this post


Link to post
Share on other sites

Yup. All your waypoints are on the same marker here.

You could use this instead of BIS_fnc_selectRandom:

fnc_rearrangeArray.sqf

private ["_array", "_newArray", "_count", "_tempIndex", "_tempValue", "_i"];

_array = _this select 0;
_newArray = [];
_count = count _array;
for "_i" from 1 to _count do {
_tempIndex = floor(random count _array);
_tempValue = _array select _tempIndex;
_array set [_tempIndex, objNull];
_array = _array - [objNull];
_newArray set [_i - 1, _tempValue];
};
_newArray;

To go a little further:

fnc_addWaypnts.sqf

private ["_i", "_wptName", "_wpts", "_tmpWpt", "_target"];

_target = _this select 0;
_wpts = _this select 1;

for "_i" from 0 to ((count _wpts) - 1) do {

_wptName = format ["_Navwaypoint%1", _i];	
missionNamespace setVariable [_wptName, _target addWaypoint [getmarkerpos (_wpts select _i), 500]]; 



_tmpWpt = missionNamespace getVariable _wptName;
_tmpWpt setWaypointType "SAD";
_tmpWpt setWaypointBehaviour "COMBAT";
_tmpWpt setwaypointcombatmode "RED"; 

if (_i < count _wpts) then
{
	_tmpWpt setWaypointSpeed "NORMAL";
	} else {
	_tmpWpt setWaypointSpeed "CYCLE";
};
};	

init.sqf

fnc_rearrangeArray = compile preprocessFile "fnc_rearrangeArray.sqf";
fnc_addWaypts = compile preprocessFile "fnc_addWaypts.sqf";

Wherever you want to create those waypoints:

if (isServer) then {
_NavChoices = ["wp1","wp2","wp3","wp4","wp5"];
_NavChoices = [_NavChoices] call fnc_rearrangeArray;
[_Navigator, _NavChoices] call fnc_addWaypts;
};

Edited by BlackMamb

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  

×