Kempco 10 Posted April 15, 2013 Trying to get a helicopter to fly to position and not land, problem is the helicopter stops short by about 50m. I used both attachTo and setvelocity to move the helicopter into position but neither seem to have an effect. The following code is from an arma 2 script used to drop units off on land and over water. AttachTo was used instead of setvelocity because attachTo does not change the VectorDir/VectorUp of the vehicle. Are the new helicopters simulated differently? If so how do you get them to fly to a specific position without landing? //by Kempco _helo = _this select 0; _endpos = _this select 1; _pilot = driver _helo; if (surfaceIsWater _endpos) then { _hlpr = JTK_Transport_Hlpr createVehicle [0,0,0]; WaitUntil {!isNil "_hlpr"}; _hlpr hideObject true; JTK_Call_PVEH = [_hlpr,compile "_this hideObject true"]; publicVariable "JTK_Call_PVEH"; While {(getpos _helo select 2 > (JTK_Transport_FlyInHeight*0.5)+1) AND (canmove _helo) AND (alive _pilot)} do {sleep 0.5}; _pos = _helo worldToModel _endpos; _dir2 = (_pos select 0) atan2 (_pos select 1); _dist2 = sqrt((_pos select 0)^2+(_pos select 1)^2); for [{_i = 0},{_i < abs(_dir2)},{_i = _i + 1}] do { _helo setdir ((getDir _helo)+abs(_dir2)/_dir2); _helo setVelocity [0,0,0]; sleep 0.05; }; _alt = getpos _helo select 2; _attachPos = [0,0,_alt]; _hlpr setDir (direction _helo); _hlpr setPos (_helo modelToWorld [0,0,-_alt]); _hlpr setVectorUp [0,0,1]; _helo attachTo [_hlpr,_attachPos]; _dir = direction _hlpr; _dist = [_helo,_endpos] call BIS_fnc_distance2D; _approachDist = (_dist*0.15); _speed = 0; _speed_max = 45; _speed_min = 1; _n = 200; _t = 0; while {(alive _pilot) AND (canmove _helo)} do { _dist_old = _dist; _dist = [_helo,_endpos] call BIS_fnc_distance2D; _speed = if (_dist > _approachDist) then { if (_speed < _speed_max) then {_speed + 0.25}else{_speed_max}; }else{ if (_speed > _speed_min) then {_speed - 0.25}else{_speed_min}; }; if (_speed == _speed_min) then {_t = _t + (1/_n)}; _inc = (_speed/_n); if ((_dist > _dist_old) OR (_dist <= 1) OR (_t > 3)) exitWith { deleteVehicle _hlpr; _helo setVelocity [0,0,0]; }; _attachPos = [_attachPos select 0,((_attachPos select 1) + _inc),_attachPos select 2]; _helo attachTo [_hlpr,_attachPos]; sleep (1/_n); }; _helo flyInHeight 5; While {(getpos _helo select 2 > 5.5) AND (canmove _helo) AND (alive _pilot)} do {sleep 0.5}; }else{ _helo land "GET OUT"; While {(getpos _helo select 2 > 1.5) AND (canmove _helo) AND (alive _pilot)} do {sleep 0.5}; }; _unitsToEject = []; {if(count(assignedVehicleRole _x) != 2 AND _x != _pilot) then {_unitsToEject = _unitsToEject + [_x]}}forEach (crew _helo); for "_i" from 0 to (count _unitsToEject - 1) do { [(_unitsToEject select _i),_helo] spawn {//<======================Give units clearence so they do not "stick" to heli WaitUntil {!((_this select 0) in (_this select 1))}; (_this select 0) setPos ((_this select 0) modelToWorld [0,1.0,-0.5]); }; unassignVehicle (_unitsToEject select _i); (_unitsToEject select _i) action ["Eject",_helo]; sleep 0.25; if !(surfaceiswater _endpos) then {_helo setVelocity [0,0,-1]}; }; sleep 1; _helo flyinheight JTK_Transport_FlyInHeight; _helo land "NONE"; Share this post Link to post Share on other sites
Mattar_Tharkari 10 Posted April 15, 2013 (edited) Is that designed to get around the waypoint completion radius problem? Eg with waypoints and doMove the heli always stops 50m short? Try deleting all waypoints - completion radius may be causing a problem somehow? The only way I managed to get that to work in Arma2 was using invisible heli pads ontop of buildings and using: heli land "land"; heli land "GET OUT" It just worked ontop of an oil tank at the airfield (with pad setPos to correct height) but is hit and miss on the terrain - above water the AI pilot will not move from the 50m radius. Some items are possibly not yet working / implemented - your script may be working against something in the pilot fsm's? @matKob Tried to use currentWaypoint and then setWaypointCompletionRadius but it didn't work. Had this problem before. You might try setting the WP 50m beyond where you want the Heli to be lol? Edited April 15, 2013 by Mattar_Tharkari Share this post Link to post Share on other sites
matkob 6 Posted April 15, 2013 Is there any way how can you change the waypoint completion radius? Share this post Link to post Share on other sites