cklymowsky 1 Posted April 1, 2018 HI All, I'm creating script to display the wayPoints of all AI groups on the screen using an "onEachFrame" in a stackedEventHandler, in order to figure what their currentWaypoint is and how it works. But, I can't figure out why the framerate goes from 40-50 fps to 1 or 0 after a few minutes when a several (10-20) groups are on screen with the script below: Thanks for any help in advance. Quote private ["_enemyArray","_distance","_displayName","_picture", "_icon", "_leader", "_alt", "_waypoint", "_text", "_grp","_randomSectorDestination","_index","_currentWaypoint"]; _distance = 0; _displayName = ""; _picture = ""; _icon = ""; _grp = objNull; _leader = leader _grp; _alt = 0; _index = 0; _text = ""; Draw3DNEWArray = []; _randomSectorDestination = ""; while {TRUE} do { _enemyArray = []; {if ((((side _x) == AIside) && (isFormationLeader _x)) or (((side _x) == AIside) && (vehicle _x != _x))) then {_enemyArray pushBackUnique (vehicle _x)}} forEach allUnits; Draw3DNEWArray = _enemyArray apply { _currentWaypoint = []; _waypoints = []; _grp = group _x; _index = currentWaypoint _grp; _waypoints = wayPoints _grp; _displayName = getText (configfile >> "CfgVehicles" >> typeOf _x >> "displayName"); _text = format ["%1 men %2 currentWaypoint %3",count units _grp, _waypoints, _index]; if ( (_x isKindOf "LandVehicle") or (_x isKindOf "Air") or (_x isKindOf "Ship") ) then { _picture = getText (configfile >> "CfgVehicles" >> typeOf _x >> "picture"); } else { _icon = getText (configFile >> "CfgVehicles" >> typeOf _x >> "Icon"); _picture = getText (configFile >> "CfgVehicleIcons" >> _icon); }; sleep 0.1; [_x,_picture,_text] }; sleep 0.1; _addNew = ["BIS_idNEW2", "onEachFrame", { _unit = objNull; _picture = ""; _text = ""; _enemyArray = _this select 0; { _unit = _x select 0; _picture = _x select 1; _text = _x select 2; drawIcon3D [ _picture, [1,0,0,1], (visiblePosition _unit) vectorAdd [0,0,10], 0.8, 0.5, 0, _text, 0, 0.03, "PuristaMedium" ]; } forEach (_enemyArray); }, [Draw3DNEWArray]] call BIS_fnc_addStackedEventHandler; }; ["BIS_idNEW2", "onEachFrame"] call BIS_fnc_removeStackedEventHandler; Share this post Link to post Share on other sites
Larrow 2820 Posted April 1, 2018 Every 0.1 seconds you are adding a new "onEachFrame" stacked event. So by the time a minute has gone by you have 60 / 0.1 = 600 stacked events trying to run each frame. 1 Share this post Link to post Share on other sites